Swap/recovery: second-pass fixes from the follow-up review
- Recovery works when another named buffer is current. On that path
OpenFile's NotifyFilenameChanged deleted the journal (old path ==
new path) that was about to be replayed; the swap was lost and the
file opened without the edits (pre-existing).
- After recovering from a journal with a torn final record, the torn
bytes are truncated before the session appends to it (ReplayFile now
reports the valid prefix length). A journal that recovers nothing is
removed instead of appended to.
- Reload restarts the journal; recovery used to replay the edits the
reload discarded.
- Opening a file that is already open switches to its buffer (in
OpenFile and before the recovery check). Two buffers for one file
interleaved records in one journal, and closing either unlinked it.
- Swap file names escape '!' and '%', so distinct paths no longer
share a journal ('/x/a!b' vs '/x/a/b'). Swap files for paths that
contain those characters get new names.
- The gap flag is cleared when the journal restarts, and a gap that
cannot be closed (buffer too large to checkpoint) is reported once.
- crc32's table is initialised thread-safely; writer-thread error
reports identify the buffer by journal path instead of racing on
Buffer::Filename(); Close() no longer retries on EINTR (the fd is
already released and may have been reused).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015rcVQiiWyTzoNrsvLSaAfB
This commit is contained in:
@@ -610,7 +610,12 @@ public:
|
||||
// Buffers hold recorders owned by the SwapManager that attached them, so
|
||||
// editors sharing buffers must also share that manager (shared_swap);
|
||||
// otherwise closing one window destroys recorders the other still uses.
|
||||
void SetSharedBuffers(std::vector<Buffer> *shared, kte::SwapManager *shared_swap = nullptr)
|
||||
// Index of the open buffer whose file is `path` (after the same
|
||||
// normalization OpenFromFile applies), or size_t(-1) if none.
|
||||
[[nodiscard]] std::size_t FindOpenBuffer(const std::string &path) const;
|
||||
|
||||
|
||||
void SetSharedBuffers(std::vector<Buffer> *shared, kte::SwapManager *shared_swap = nullptr)
|
||||
{
|
||||
shared_buffers_ = shared;
|
||||
shared_swap_ = shared ? shared_swap : nullptr;
|
||||
|
||||
Reference in New Issue
Block a user