Skip to content

fix(discovery): do not block directories with an invalid server mtime - #11387

Open
guettli wants to merge 1 commit into
nextcloud:masterfrom
guettli:fix/directory-invalid-remote-mtime
Open

guettli wants to merge 1 commit into
nextcloud:masterfrom
guettli:fix/directory-invalid-remote-mtime

Conversation

@guettli

@guettli guettli commented Nov 21, 2026 •

Copy link
Copy Markdown

Resolves

Summary

A directory with an invalid mtime on the server (0 / 1970-01-01) was marked as
an error during discovery ("Cannot sync due to invalid modification time"), so
the directory and everything below it never synced. I hit this with a music
library copied into a user's data directory with rsync -a: one folder had
mtime 0, and its 101 files were blocked.

A directory's mtime is only applied once, when the directory is created
locally, so it should not block the sync. Directories now get a valid
fallback (the journal's, else the local mtime, else now). The check for files
is unchanged, and the journal keeps its modtime > 0 invariant.

How to verify: on the server, touch -d @0 a folder with files in it and
run occ files:scan; the client syncs it instead of reporting the error.

End-to-end check (run with Claude Code): nextcloudcmd built from this branch
against a fresh Nextcloud 35.0.3 server, a folder with files touched to mtime 0
and rescanned. Without the fix the folder fails with "Cannot sync due to
invalid modification time" and only the other folder syncs; with the fix
everything syncs, and the substituted mtime stays the same on the next sync.

New tests TestSyncEngine::testDirectoryInvalidRemoteMtime and
TestSyncVirtualFiles::testDirectoryInvalidRemoteMtime:

  • without the fix: FAIL (fakeFolder.syncOnce() returned FALSE)
  • with the fix: PASS; SyncEngineTest, SyncVirtualFilesTest and
    LocalDiscoveryTest all pass (CI image client-sid-6.10.2-4)

Checklist

AI (if applicable)

The fix and test were written with Claude Code; I reviewed and verified them.

@guettli
guettli force-pushed the fix/directory-invalid-remote-mtime branch from 734fb2b to f2ad508 Compare November 21, 2026 16:36
A directory whose server-side mtime is invalid (0, e.g. a folder that
ended up with 1970-01-01 after being copied into the data directory)
was marked as an error during discovery ("Cannot sync due to invalid
modification time"). The whole directory and everything below it then
stayed unsynced, although a directory's mtime is only applied once,
when it is created locally.

Replace an invalid server mtime of a directory right where the server
entries are processed, before any comparison: the journal value, else
the local mtime, else the current time. The journal value comes first
because it is stable, so the directory is not seen as changed on every
sync. This keeps the journal invariant (modtime > 0) and leaves the
check for files unchanged.

Assisted-by: ClaudeCode:claude-opus-5-5
Signed-off-by: Thomas Güttler <info@thomas-guettler.de>
@guettli
guettli force-pushed the fix/directory-invalid-remote-mtime branch from f2ad508 to b28e791 Compare November 22, 2026 11:04
@guettli
guettli marked this pull request as ready for review November 22, 2026 16:01
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