diff --git a/docs/CACHE-RECOVERY.md b/docs/CACHE-RECOVERY.md new file mode 100644 index 0000000..b6029a9 --- /dev/null +++ b/docs/CACHE-RECOVERY.md @@ -0,0 +1,64 @@ +# Cache metadata recovery + +“Cache metadata needs attention” means rclone's local status API responded, but +ResoDrive could not parse one of its cache metadata files. This differs from an +unavailable status API. The drive stays protected: uncertain metadata cannot +authorize unmounting, installation preparation or a clean-cache verdict. Earlier +pending-upload counts remain visible until a complete fresh observation succeeds. + +Open the drive's error-details button, then choose **Back up and recheck**. Close +applications using the drive first. Recovery requires the original, verified +rclone process and its protected loopback credentials. It does not remount the +drive, stop a process, run an upload or edit metadata itself. + +For the first damaged entry, recovery: + +1. Rejects linked/escaped cache paths and backup/cache overlap. +2. Takes stable copies of the metadata and cached file while denying writes and + deletion, flushes them to disk, and verifies their SHA-256 hashes. +3. Writes a manifest with the relative filename and original hashes in + `%USERPROFILE%\ResoDrive-Recovery\entry--`. +4. Downloads a separate server copy directly through rclone's authenticated + `operations/copyfile` endpoint, with the recovery folder as its only destination. +5. Compares the complete file hashes and rechecks the active cache and process. + Different server bytes, concurrent changes, cancellation, locks or account + cleanup stop recovery and retain any backup files already created. +6. Only for matching bytes, reads the mounted file without write access so rclone + can refresh its own metadata. The read must match the verified copy; metadata + must become valid, clean, and have the matching size before reporting success. + +Rclone can defer its cache close/write for its write-back interval. Recovery waits +briefly for valid metadata; a timeout never authorizes a clean verdict. Normal +host polling independently checks the entire drive afterward. Other damaged +entries or pending uploads can therefore keep the drive's warning active. + +Backups are external user exports and remain outside normal managed-cache and +Nextcloud wipe coverage. They may contain private data. Keep them until recovery +has been reviewed. Do not delete a mismatching cached copy, trim malformed JSON +to make it appear clean, or restore a backup over a live cache. If automatic +rechecking cannot finish, preserve both copies for manual comparison/recovery. + +## Verification on 28 November 2026 + +A live malformed entry was backed up together with its cached file. A separate +read from the actual server matched the cached file's SHA-256. A read-only mount +read let rclone regenerate valid metadata. The installed host then reported +`Mounted`, `No queued uploads`, fresh upload status and no recovery requirement. +No server write, cache deletion, forced stop or manual metadata edit was used. +The private backup manifest and server-verification receipt are retained locally; +private filenames and account details are not part of this repository. + +Regression tests use disposable files. They cover exact backups, different server +content, concurrent edits, cancellation, locked data, changed account/process +checks, unsafe backup locations, malformed/dirty/wrong-size post-read metadata, +preserved pending counts, and the new protocol/UI/diagnostic distinction. A real +rclone VFS/WebDAV test reproduces trailing metadata corruption and verifies +read-driven repair against a disposable local backend. It uses no production +account or wipe token. Compiled UI checks cover progress, cancellation, backup +access and layout at 100%, 150% and 200% display scale. + +The complete local build passed 1,481 tests (Core 206, Windows 825, App 450), +with two optional/elevation-dependent cases skipped. All 450 App tests also passed +with one available CPU. MSI and Setup compiled with zero warnings and errors. +This verifies local tests and packaging; it is not an installed-app upgrade or +publication of a new release. diff --git a/src/ResoDrive.App/CacheRecoveryWindow.xaml b/src/ResoDrive.App/CacheRecoveryWindow.xaml new file mode 100644 index 0000000..7b0074b --- /dev/null +++ b/src/ResoDrive.App/CacheRecoveryWindow.xaml @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + +