Skip to content

Preserve data when file operations or settings saves fail - #639

Open
lellomele wants to merge 2 commits into
derceg:masterfrom
lellomele:fix/data-integrity
Open

lellomele wants to merge 2 commits into
derceg:masterfrom
lellomele:fix/data-integrity

Conversation

@lellomele

Copy link
Copy Markdown

Merge/split operations could skip unreadable inputs, truncate large files or report success after incomplete writes. Settings saves could overwrite XML directly or remove the registry profile before its replacement was written. This change preserves existing data when an operation fails or is cancelled.

  • Copy merge/split inputs in bounded chunks using checked 64-bit sizes, complete short transfers, and report read/write/flush failures. Publish only completed outputs without overwriting existing destinations, and roll back files owned by an unsuccessful operation.
  • Keep the merge order consistent with the displayed list. Make the dialogs own and join their workers; X and Esc request cancellation and wait for cleanup. Register synchronous I/O cancellation only around interruptible work, so a late stop cannot interrupt rollback.
  • Share the output-file guard with XML settings and UTF-16 directory listings. XML replacement keeps the previous version as .bak; loading can recover a valid backup while protecting both files from automatic overwrites.
  • Save the registry snapshot in a Windows transaction, explicitly enlisting child keys. Collect failures from the existing serializers and return a failed commit instead of publishing partial settings. Report save/load failures rather than silently changing storage after an unreadable configuration.
  • Check GetAnyOperationsAborted after shell file operations so an aborted batch is not recorded as successful.

The first commit isolates the locale change needed to run the regression suite under either English or Italian Windows settings. Production callers retain their existing system-locale formatting. The second commit contains the data-integrity changes, component tests, history entries and user documentation. Generated translations are left to the normal Crowdin workflow; new messages have an English fallback.

Validation on the proposed tree, based on current master (62dc36c):

  • Full Release x64 solution build with MSVC 14.51 and Windows SDK 10.0.26100.0, including the application, resources, tests and MSI.
  • 937/937 tests passed, none skipped or disabled, in Windows Sandbox with it-IT settings. This includes 36 added regressions.
  • A real 4 GiB + 37 byte split/merge round trip, comparing both parts and the recombined file byte for byte. The test releases an already verified zero range between stages to keep peak disk usage near 4 GiB; both transfers use real WriteFile calls.
  • 6/6 real application checks for XML/registry save and reload and cancellation of merge/split using X and Esc, followed by 20/20 repeated cancellations (five per mode).
  • Size-format tests under both it-IT and en-US (3/3 for the English run), preserving 1,00 KB and 1.00 KB respectively.

The negative tests cover existing/locked/read-only destinations, missing inputs, short transfers, unexpected EOF, simulated disk-full and flush failures, cancellation before publication, rollback ownership, denied registry access, abandoned transactions, malformed XML and backup recovery. Test execution was isolated in Windows Sandbox with networking and clipboard sharing disabled.

Limits: this does not merge conflicting settings from independent instances; sequential saves still use the last snapshot. Publishing multiple split parts is not a filesystem-wide transaction, so forced termination may leave complete parts or temporary files. Other architectures and sanitizer/Clang configurations remain subject to the repository's CI checks.

This branch has not been deployed

No deployments
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.

1 participant