Skip to content

fix(dav): apply client-provided mtime before cache update#58983

Draft
joshtrichards wants to merge 1 commit intomasterfrom
jtr/fix-dav-put-mtime-ordering
Draft

fix(dav): apply client-provided mtime before cache update#58983
joshtrichards wants to merge 1 commit intomasterfrom
jtr/fix-dav-put-mtime-ordering

Conversation

@joshtrichards
Copy link
Member

Summary

When a sync client uploads a file with an x-oc-mtime header, the provided mtime is applied after $storage->getUpdater()->update() runs. The scanner inside update() reads the filesystem mtime via stat(), which at that point reflects the current server time -- not the client-provided value. This means the cache is briefly populated with the wrong mtime before View::touch() corrects it.

Additionally, View::touch() goes through basicOperation, which can trigger writeUpdate() hooks/updater side effects depending on the view's state -- an unnecessary risk given the DAV code already manages the updater manually.

Changes introduced by this PR:

  • Call $storage->touch($internalPath, $mtime) before the updater, so the scanner sees the correct mtime from the filesystem.
  • If the native touch fails (some backends don't support it), write mtime directly to the filecache via putFileInfo.
  • Consolidate upload_time, mtime (fallback), and creation_time into a single putFileInfo call.
  • Remove the View::touch() call entirely.

TODO

  • ...

Checklist

AI (if applicable)

  • The content of this PR was partly or fully generated using AI

The x-oc-mtime header was applied after the cache updater scanned the file, meaning the scanner would briefly write the current time() to the cache before it was corrected. This created a small window where the wrong mtime was visible, and triggered a redundant cache write.

Signed-off-by: Josh <josh.t.richards@gmail.com>
@joshtrichards joshtrichards added 3. to review Waiting for reviews feature: filesystem feature: dav hotspot: file time handling ctime, mtime, etc. handling during various operations hotspot: file transfer performance upload & download performance related optimizations enhancement labels Mar 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3. to review Waiting for reviews enhancement feature: dav feature: filesystem hotspot: file time handling ctime, mtime, etc. handling during various operations hotspot: file transfer performance upload & download performance related optimizations

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: 32.0.5.0 (client 3.17.4) etag changes on unchanged file

1 participant