Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fix(FileCache): mtime when not provided backend at zero
Signed-off-by: Adrien "ze" Urban <[email protected]>
  • Loading branch information
ze42 committed May 17, 2024
commit 627528fcd48f71805d721dc4282d335d86e9a2d0
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 (array_key_exists('mtime', $data) && $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