Repository navigation
fix(posix): keep files findable by id after their folder is renamed on disk - #850
Open
NickWalters wants to merge 1 commit into
Open
NickWalters wants to merge 1 commit into
NickWalters wants to merge 1 commit into
Conversation
After a directory is moved on disk, the watcher walks it again to update the cached paths of its children. That walk only looks at dirty directories, and a moved directory is not marked dirty, so a directory that was already scanned is skipped as a whole. Its children keep no valid id cache entry, and looking them up by id fails until someone lists the folder or the service restarts. Walk the moved directory in full, like Tree.Move does for moves through the API.
NickWalters
force-pushed
the
fix/posix-moved-dir-child-ids
branch
from
October 6, 2026 06:40
5b7dbfe to
85c5042
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #855.
Problem
With the posix driver and the watcher on, rename a folder on disk. Afterwards, files inside it can't be found by id. Shares, public links, favourites and
fileidURLs that point at those files fail until someone opens the folder in OpenCloud or the service restarts.It only happens to folders that were already scanned, which after a restart means every existing folder. Brand-new folders are still dirty and work.
How to reproduce
awith a filea/f.txtin it.mv a bon disk.f.txtby its id. The id cache has no path for it, so the lookup fails.Cause
After a move,
assimilatewalks the moved folder to update the cached paths of its children, withWarmupIDCache(item.Path, false, true). WithonlyDirtyset, the walk skips clean folders. A folder moved on disk is not marked dirty, so the walk skips the moved folder as a whole and never reaches the children.Fix
Walk the moved folder in full (
onlyDirty=false).Tree.Movealready does this for moves through the API.Tests
The new spec in
tree_test.godoes the steps above. It runs a full warmup before the move, because a folder only becomes clean once a walk has passed over it. It fails on main (3 of 3 runs) and passes with this change. The same spec without that warmup passes on main, which confirms it's the clean-folder case.go test -race ./pkg/storage/fs/posix/...passes and golangci-lint is clean. The tree package fails now and then in the sharedBeforeEach(tree_test.go:55, the watcher doesn't pick up the new test folder within 15 s). That happens on main too: 1 of 30 runs here, with or without this change.Together with #849 the moved folder also keeps its tree size. Without #849, the follow-up walk can still reset it, because it writes 0 for the clean folders it skips.
This merges cleanly with #808, #849 and #853, which change the same walk.