Skip to content

Commit

Permalink
fix(files): Preserve directory mtime on rename and move
Browse files Browse the repository at this point in the history
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
  • Loading branch information
come-nc committed Feb 22, 2024
1 parent e8dd410 commit 679f1d6
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/private/Files/Storage/Common.php
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,10 @@ public function copy($source, $target, bool $preserveMtime = false): bool {
}
}
closedir($dir);
if ($preserveMtime) {
$mtime = $this->filemtime($source);
$this->touch($target, is_int($mtime) ? $mtime : null);
}
return true;
} else {
$sourceStream = $this->fopen($source, 'r');
Expand Down Expand Up @@ -637,6 +641,10 @@ public function copyFromStorage(IStorage $sourceStorage, $sourceInternalPath, $t
$result = $this->copyFromStorage($sourceStorage, $sourceInternalPath . '/' . $file, $targetInternalPath . '/' . $file, $preserveMtime);
}
}
if ($result && $preserveMtime) {
$mtime = $sourceStorage->filemtime($sourceInternalPath);
$this->touch($targetInternalPath, is_int($mtime) ? $mtime : null);
}
}
} else {
$source = $sourceStorage->fopen($sourceInternalPath, 'r');
Expand Down

0 comments on commit 679f1d6

Please sign in to comment.