Skip to content

Keep the source when it changes during a cross-Library move - #140

Merged
Orkas-AI merged 1 commit into
Orkas-AI:mainfrom
arxhr007:fix/131-library-move-source-changed
Oct 31, 2026
Merged

Orkas-AI merged 1 commit into
Orkas-AI:mainfrom
arxhr007:fix/131-library-move-source-changed

Conversation

@arxhr007

Copy link
Copy Markdown
Contributor

Fixes #131.

Problem

Moving an entry between Libraries copies it to the destination and then deletes the source. If the source is edited after the copy was written but before the delete, the edit is lost: the move reports success and only the old contents remain at the destination.

Change

transferLibraryEntries now fingerprints the source (path, size and mtime of every entry) before the copy and checks it again just before the delete. If it changed, the source is kept and the destination copy is rolled back, the same way as when the source cannot be removed. The result uses the existing source_delete_failed error, so no new text is needed.

The check happens immediately before the delete, which closes the window described in the issue but not the instant between the check and the delete itself.

Tests

test/main/features/library_transfer_source_changed.test.ts covers a file edited during the copy, a file added to a moved folder during the copy, and an unchanged source that is still deleted. The first two fail without the change.

I ran the three library transfer test files with vitest on Node 22 (25 tests pass) and tsc --noEmit. I did not run the full suite under Electron.

A move between Libraries copies the entry and then deletes the source. An
edit saved after the copy was written but before the delete was lost: the
move succeeded and only the old contents remained at the destination.

Fingerprint the source (path, size and mtime of every entry) before the
copy and compare it again just before the delete. If it changed, skip the
delete and roll the destination copy back, reporting source_delete_failed
like any other source that could not be removed.

Fixes #131
@Orkas-AI

Copy link
Copy Markdown
Owner

Thanks for the contribution! We'll review how this handles concurrent edits and rollback before deciding whether to merge it.

@Orkas-AI
Orkas-AI merged commit bf4abab into Orkas-AI:main Oct 31, 2026
Orkas-AI pushed a commit that referenced this pull request Oct 31, 2026
Build on the source-change protection in PR #140. Capture bounded revisions
without following symlinks, fail closed when metadata cannot be read, and
verify the source immediately before native removal after awaited validation.
Include inode and nanosecond change timestamps to detect replaced files whose
size and modification time remain unchanged. Retain the completed copy after
a partial source deletion so recovery cannot discard the remaining full data.

Verification: 171 existing affected tests passed before the changes. Seven
filesystem regressions fail with the original transfer module and pass with
this change; final affected selection passes all 183 cases under Electron with
clean log analysis. Main and core-agent typechecks pass. For 1000 files, median
revision capture was 9.83 ms asynchronously and final synchronous verification
was 2.99 ms; collection/verification and snapshot sizes have explicit bounds.
@Orkas-AI

Copy link
Copy Markdown
Owner

Thank you for your contribution to Orkas! We really appreciate your time and effort.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

File edits can disappear during a move between Libraries

2 participants