Repository navigation
Audit 2026-10-14: Recycle Bin mode could delete permanently; wrong-target, cloud-file and long-path fixes - #1
Conversation
IFileOperation was driven with FOF_NOCONFIRMATION, which also answers the shell's own "this cannot be recycled, delete it permanently?" question with yes. Windows has no Recycle Bin on network shares and many removable drives, and will not recycle an item larger than the bin's maximum size or on a drive whose bin is turned off. Such an item was destroyed, and the deleter reported it as moved to the Recycle Bin. The shell makes that decision for a whole batch. Reproduced on this machine: a two-item Recycle Bin batch of one local temp file and one file reached through \\localhost\C$ deleted both permanently. The local file never reached the bin and both outcomes said success. Every cleanup, Smart Cleaner and duplicate path that offers "Recycle Bin (recoverable)" goes through it, and a batch is up to 512 items. Each recycled item now carries a per-item IFileOperationProgressSink. PreDeleteItem carries TSF_DELETE_RECYCLE_IF_POSSIBLE only when the item is headed for the bin; without it the sink returns E_ABORT, which stops the item and everything still pending before anything is deleted. This is the check Electron uses for shell.trashItem. After a stopped batch, items already recycled are reported as recycled and the rest are retried one by one, where the shell judges each item alone and a refusal is final: "Not deleted", with the reason. A one-item recycle is now existence-checked like a batch. RecycleBinGuardTests use the loopback admin share as a location without a Recycle Bin, so no system setting is touched, and return early where the share is unavailable. Three of them fail on the previous code with the file destroyed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
VideoPHashStrategy_IsAvailable_TracksLatestSettingsValue empties the process-wide PATH. xUnit runs test classes in parallel, so ExternalProcessRunnerTests, which starts powershell.exe by name, failed at random with "file not found" (seen locally in a full run). powershell.exe is not in System32, so only PATH finds it. The class now runs in its own non-parallel collection, the same way LocalizationCatalogTests isolates the process-wide language. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
580bd52 deleted docs/public/ROADMAP.md and the archived AIprojectcontext pack, but CODEMAP.md still listed ROADMAP.md as a solution file and pointed at the archived pack, V2_PLAN.md sent readers to ROADMAP.md for the current plan, and archive/README.md described a pack that is no longer there. No product file or README link was affected. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
TryNormalizeRequest canonicalised every request with Path.GetFullPath, which, like Win32 path resolution and every .NET file API given a plain path, trims trailing spaces and dots from each segment. A request for C:\x\victim. became C:\x\victim: a different entry the user never selected. Without an expected snapshot, which the cache, browser and Windows-component rules do not set, the deleter removed that sibling and reported success. Reproduced in the new test for "victim.", "victim ", "victim. ." and "sub.\victim". Such names exist only when created through \\?\ paths, by WSL, or by tools from other systems. A plain path cannot address them, so the request is now refused with an explanation for every deletion method. \\?\ paths are not normalised and still pass. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…cleanup Nothing looked at FILE_ATTRIBUTE_RECALL_ON_DATA_ACCESS or FILE_ATTRIBUTE_OFFLINE, which the scanner already records from the enumeration buffer. - Duplicate detection: every strategy reads content (partial hash, SHA-256, image decode, ffmpeg, text). Reading a OneDrive online-only placeholder downloads the whole file, so a duplicate run over a synced folder hydrated every same-size cloud file onto the disk the user was trying to clean. The candidate query now skips files whose content is not on the disk. Pinned and locally available cloud files are unaffected. - Large old files: an online-only file has a large logical size but takes no local space. The rule offered it as reclaimable, and deleting it freed nothing while removing the cloud copy. It is now skipped. RemoteContentAttributes holds the mask in one place. Folder totals still count logical size; see the PR notes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
.NET prefixes long paths for its own file APIs, but the no-follow guards call CreateFileW through P/Invoke with the string as given. Windows rejects a plain path over MAX_PATH with ERROR_PATH_NOT_FOUND unless the machine-wide LongPathsEnabled policy is on, and it is off by default. The guards read "not found" as "vanished". So on a default install: - FileDeleter's permanent recursive delete returned without deleting a long root folder, and the request was reported as a success - nested long folders were skipped, and the parent delete then failed - NoFollowFileEnumerator reported long folders and files as "not found", so cleanup analysis missed what was inside them DirectoryTraversalInterop.ToWin32Path now adds \\?\ (or \\?\UNC\) from the CreateDirectory limit upward. It is used by every raw CreateFileW call, including the bulk identity read. Short paths are passed through unchanged. This machine has LongPathsEnabled=1, so the failure cannot be reproduced here without changing a system setting. The tests pin the conversion and an end-to-end delete and enumeration of a 300-character tree. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
3a9c143 to
4a35307
Compare
With the Recycle Bin guard's progress sink attached, the shell recycles everything else and then reports a batch that skipped a locked file as aborted. Without a sink it reports success. That sends the batch down the retry-individually route, so this pins that items already in the bin are still reported as recycled, not as "changed or replaced" by a per-file retry, and that only the locked file fails. The comment that said the shell reports success corrected to match. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Second-pass review: StorageMaster PR #1 (audit/2026-10-14)Verdict: safe to merge. I found no bug in the changes, so I pushed no commits. The points under "Remaining concerns" are judgement calls or follow-ups, not blockers. What I checkedRecycle Bin guard (
Mutation test. I made Names ending in a space or a dot
Long paths
Cloud placeholders
Tests
Localisation. The PR adds no CI, run locally in a clean worktree on bbc1b43, exactly as
Remaining concerns (not fixed; judgement calls or follow-ups)
No commits pushed by this review; CI on bbc1b43 is green. 🤖 Generated with Claude Code |
Summary
StorageMaster audit, 2026-10-14. I reviewed deletion safety first, then scanning and robustness; the fixes below are all on the deletion and cloud-file side. Each fix below was reproduced on the original code before it was changed, except the long-path fix, which this machine's settings hide (see below).
FileDeleterdroveIFileOperationwithFOF_NOCONFIRMATION. That flag also answers the shell's own "this cannot be recycled, delete it permanently?" prompt with yes. It applies to network shares, many removable drives, items larger than the bin's maximum size, and drives where the bin is turned off. Such an item was destroyed, and the app said it was "moved to the Recycle Bin (recoverable)".\\localhost\C$deleted both permanently: the Recycle Bin item count was unchanged and both outcomes said success. Cleanup, Smart Cleaner, duplicates and scheduled cleanup all use this path, with batches of up to 512 items.Path.GetFullPath, and Win32 path resolution generally, trims those characters. A request for…\victim.therefore deleted the unselected sibling…\victimand reported success. Reproduced forvictim.,victim,victim. .andsub.\victim.CreateFileWwith plain paths. Windows answered "not found" beyond 260 characters, and the guards read that as "already deleted". A permanent delete of such a folder reported success while nothing was deleted.Changes
Deletion safety
fix(delete): Recycle Bin mode no longer deletes permanently.IFileOperationProgressSink(RecycleOnlyProgressSink).PreDeleteItemsetsTSF_DELETE_RECYCLE_IF_POSSIBLEonly when the item is headed for the bin. Without that flag, the sink returnsE_ABORT, which stops the operation before anything is touched. This is the same check Electron uses forshell.trashItem.fix(delete): refuse names ending in a space or a dot, for every method.\\?\paths are exact and still pass.fix(paths): rawCreateFileWcalls use the\\?\form for paths of 248 characters or more (DirectoryTraversalInterop.ToWin32Path). Short paths are unchanged. This covers the delete guards,NoFollowFileEnumeratorand the bulk identity read.test(delete): pins batch outcomes when the shell skips a locked file. With the sink attached, the shell flags such a batch as aborted.Scanning and cloud files
fix(cloud):FILE_ATTRIBUTE_RECALL_ON_DATA_ACCESSorFILE_ATTRIBUTE_OFFLINE, which the scanner already records. Pinned or locally available cloud files are still compared.Tests and CI
test: one ffmpeg test empties the process-widePATHwhile other classes run in parallel. That madeExternalProcessRunnerTests(powershell.exestarted by name) fail at random with "file not found"; seen locally. That class now runs in its own non-parallel collection.Docs
docs: CODEMAP, V2_PLAN and archive/README still pointed at files removed in580bd52(docs/public/ROADMAP.md, the archived AIprojectcontext pack). README links and product files were not affected; every relative Markdown link resolves.[Unreleased], ARCHITECTURE.md and SAFETY_RECOVERY.md describe the new Recycle Bin behaviour.Verification
ci.ymlstep run locally in the worktree on the final tree:cargo fmt --check,cargo clippy --all-targets --all-features -D warnings,cargo test,cargo build --releasedotnet format --verify-no-changesdotnet build -c Release(0 errors; the only warnings are the ImageSharp advisories below)dotnet testwithSTORAGEMASTER_REQUIRE_TURBO_SCANNER=true: 567 passed, 1 intentional skip (550 + 1 skip at the start)RecycleBinGuardTests: 3 tests fail on the original code with the file destroyed. They use the loopback admin share as a location without a Recycle Bin, so no system setting is changed, and return early where the share is unavailable.DeleteAsync_NameEndingInDotOrSpace_DoesNotDeleteTheTrimmedSibling: 5 cases fail, 4 of them with the sibling deleted.SHQueryRecycleBincounts:LongPathsEnabled=1, so the failure cannot be reproduced without changing a system setting. The tests pin the path conversion and an end-to-end delete and enumeration of a 300-character tree.build-and-testgreen on every push, including the final commit (bbc1b43).Deliberately left alone
ImageSharp advisories (
dotnet list package --vulnerable).SixLabors.ImageSharp3.1.12 has 3 high and 2 moderate advisories, published 2026-10-07. They are fixed only in 4.1.2; no 3.1.x patch exists. 4.x refuses to build without a Six Labors license key ("No Six Labors license found"). The license text itself is unchanged..tifis a supported extension).Default deletion behaviour is unchanged. Recycle Bin is still the default, and nothing new is offered. Items Windows cannot recycle are refused, not silently made permanent.
Size accounting:
Changing any of this is a product decision (question 3).
The Duplicates page does not say why a selected file was not deleted (changed since analysis, locked, or now "Recycle Bin unavailable"). The status line shows a lower count and the file stays listed. A proper fix needs new strings in all three languages and UI work I could not verify visually, so it is left as a follow-up.
Cancel in the shell's progress dialog during a recycle batch cannot be told apart from a skipped locked file: both return S_OK with "aborted". So the remaining items are still retried individually, as before.
ExternalProcessRunnerTests.RunAsync_Cancellation_KillsProcessBeforeDelayedMutationexceeded its 8 s bound once (10.6 s) during a full run on a heavily loaded machine. It passed on every rerun, so its timeout is unchanged.Robustness: reviewed, left as is. Unhandled-exception logging (
logs/startup-errors.log) and settings persistence (one SQLite row with transactional updates) looked sound. The elevation and elevated-scan worker code paths were not reviewed in depth.Duplicate finder and the last copy: no issue found.
Final path-based API boundary. Recycle and single-file deletes still cross one path-based Windows API boundary after the snapshot check. This is already documented in SAFETY_RECOVERY.md.
Open questions for you
.tif/.tifffrom image duplicate detection)?Running the tests sends a few tiny temp files to the Recycle Bin of the machine running them, as the existing batch tests already did. They are named
storagemaster-test-recycle-*andsmhard_batch_*.🤖 Generated with Claude Code