Skip to content

Commit 30d712d

Browse files
committed
fix(FileCache): mtime when not provided backend at zero
Signed-off-by: Adrien "ze" Urban <spam@hagtheil.net>
1 parent 495d397 commit 30d712d

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

lib/private/Files/Cache/Cache.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,12 @@ public function put($file, array $data) {
278278
* @throws \RuntimeException
279279
*/
280280
public function insert($file, array $data) {
281+
// Some storage always return mtime at 0.
282+
// Use now as time if nothing else is provided
283+
if ($data["mtime"] === 0) {
284+
$data["mtime"] = time();
285+
}
286+
281287
// normalize file
282288
$file = $this->normalize($file);
283289

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

440446
$doNotCopyStorageMTime = false;
441-
if (array_key_exists('mtime', $data) && $data['mtime'] === null) {
447+
// some storage always have mtime null or zero, do use that
448+
if (array_key_exists('mtime', $data) && ($data['mtime'] === null || $data['mtime'] === 0)) {
442449
// this horrific magic tells it to not copy storage_mtime to mtime
443450
unset($data['mtime']);
444451
$doNotCopyStorageMTime = true;

0 commit comments

Comments
 (0)