fix(files): Preserve directory mtime on rename and move

Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
This commit is contained in:
Côme Chilliet 2024-02-22 11:40:00 +01:00
parent a9c3a148f6
commit f9b4cf417a
No known key found for this signature in database
GPG key ID: A3E2F658B28C760A

View file

@ -240,6 +240,10 @@ abstract class Common implements Storage, ILockingStorage, IWriteStreamStorage,
}
}
closedir($dir);
if ($preserveMtime) {
$mtime = $this->filemtime($source);
$this->touch($target, is_int($mtime) ? $mtime : null);
}
return true;
} else {
$sourceStream = $this->fopen($source, 'r');
@ -637,6 +641,10 @@ abstract class Common implements Storage, ILockingStorage, IWriteStreamStorage,
$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');