Skip to content

Commit

Permalink
fix(FileCache): mtime when not provided backend at zero
Browse files Browse the repository at this point in the history
Signed-off-by: Adrien "ze" Urban <spam@hagtheil.net>
  • Loading branch information
ze42 committed May 17, 2024
1 parent 495d397 commit 07de83b
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/private/Files/Cache/Cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,12 @@ public function put($file, array $data) {
* @throws \RuntimeException
*/
public function insert($file, array $data) {
// Some storage always return mtime at 0.
// Use now as time if nothing else is provided
if ($data["mtime"] === 0) {
$data["mtime"] = time();
}

// normalize file
$file = $this->normalize($file);

Expand Down Expand Up @@ -438,7 +444,8 @@ protected function normalizeData(array $data): array {
$extensionFields = ['metadata_etag', 'creation_time', 'upload_time'];

$doNotCopyStorageMTime = false;
if (array_key_exists('mtime', $data) && $data['mtime'] === null) {
// some storage always have mtime null or zero, do use that
if (array_key_exists('mtime', $data) && $data['mtime'] === null || $data['mtime'] === 0)) {
// this horrific magic tells it to not copy storage_mtime to mtime
unset($data['mtime']);
$doNotCopyStorageMTime = true;
Expand Down

0 comments on commit 07de83b

Please sign in to comment.