Skip to content

fix(files): preserve mtimes when copying and moving#62429

Open
mh0pe wants to merge 3 commits into
nextcloud:masterfrom
mh0pe:codex/issue-15192-preserve-mtime
Open

fix(files): preserve mtimes when copying and moving#62429
mh0pe wants to merge 3 commits into
nextcloud:masterfrom
mh0pe:codex/issue-15192-preserve-mtime

Conversation

@mh0pe

@mh0pe mh0pe commented Jul 22, 2026

Copy link
Copy Markdown

Summary

  • preserve file and directory mtimes for same-storage and cross-storage copies
  • preserve mtimes recursively when moves fall back to copy and delete
  • retain known mtimes across storage-wrapper renames and moves
  • keep View::copy(..., false) as an explicit opt-out

Fixes #15192

Why

Nextcloud already preserves the logical mtime in the file cache while tracking the backing storage timestamp separately as storage_mtime. The storage operations did not apply that model consistently: View::copy() ignored its preservation flag, recursive storage copies dropped the flag, the local fallback dropped it, and the known-mtime wrapper read timestamps after paths had moved.

The copied or moved node now retains its content chronology while the destination parent's mtime and etag still record the operation. Directory copies restore mtimes bottom-up in a post-copy traversal, avoiding a public IStorage signature change for third-party storage implementations.

Validation

  • affected PHPUnit suites: 622 tests, 2,259 assertions, 3 skips; all passing
  • PHP syntax checks: passing
  • XML validation: passing
  • PHP CS Fixer dry run: passing
  • git diff --check: passing
  • Psalm reported 16 missing Imagick symbols outside the changed files; no Psalm errors were reported in the changed production files

@mh0pe
mh0pe marked this pull request as ready for review July 23, 2026 00:30
@mh0pe
mh0pe requested a review from a team as a code owner July 23, 2026 00:30
@mh0pe
mh0pe requested review from Altahrim, come-nc, leftybournes and salmart-dev and removed request for a team July 23, 2026 00:30
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.

Consistent handling of last modified dates when copying/moving files

1 participant