Skip to content
Prev Previous commit
Next Next commit
fix: Fix mtime preservation on rename in KnownMtime wrapper
Signed-off-by: Côme Chilliet <[email protected]>
  • Loading branch information
come-nc committed Feb 22, 2024
commit d176d3cd9a55c2c4a643bc7672bbd8a5e2d6d6f9
5 changes: 3 additions & 2 deletions lib/private/Files/Storage/Wrapper/KnownMtime.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public function unlink($path) {
public function rename($source, $target) {
$result = parent::rename($source, $target);
if ($result) {
$this->knowMtimes->set($target, $this->clock->now()->getTimestamp());
$this->knowMtimes->set($target, $this->filemtime($source));
$this->knowMtimes->set($source, $this->clock->now()->getTimestamp());
}
return $result;
Expand Down Expand Up @@ -125,9 +125,10 @@ public function copyFromStorage(IStorage $sourceStorage, $sourceInternalPath, $t
}

public function moveFromStorage(IStorage $sourceStorage, $sourceInternalPath, $targetInternalPath) {
$mTime = $sourceStorage->filemtime($sourceInternalPath);
$result = parent::moveFromStorage($sourceStorage, $sourceInternalPath, $targetInternalPath);
if ($result) {
$this->knowMtimes->set($targetInternalPath, $this->clock->now()->getTimestamp());
$this->knowMtimes->set($targetInternalPath, $mTime);
}
return $result;
}
Expand Down