Skip to content

fix(posix): keep files findable by id after their folder is renamed on disk - #850

Open
NickWalters wants to merge 1 commit into
opencloud-eu:mainfrom
NickWalters:fix/posix-moved-dir-child-ids
Open

NickWalters wants to merge 1 commit into
opencloud-eu:mainfrom
NickWalters:fix/posix-moved-dir-child-ids

Conversation

@NickWalters

@NickWalters NickWalters commented Oct 6, 2026 •

Copy link
Copy Markdown

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 fileid URLs 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

  1. Start OpenCloud with a posixfs space and the watcher on. Have a folder a with a file a/f.txt in it.
  2. Restart, so the startup scan marks every folder as clean.
  3. mv a b on disk.
  4. Look up f.txt by its id. The id cache has no path for it, so the lookup fails.

Cause

After a move, assimilate walks the moved folder to update the cached paths of its children, with WarmupIDCache(item.Path, false, true). With onlyDirty set, 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.Move already does this for moves through the API.

Tests

The new spec in tree_test.go does 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 shared BeforeEach (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.

@NickWalters NickWalters changed the title fix(posix): files in a folder renamed on disk can't be found by id fix(posix): keep files findable by id after their folder is renamed on disk Oct 6, 2026
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.
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.

posix: files in a folder renamed on disk can't be found by id

1 participant