diff --git a/apps/dav/lib/Connector/Sabre/File.php b/apps/dav/lib/Connector/Sabre/File.php index f200838ba6bde..b55296b13ef77 100644 --- a/apps/dav/lib/Connector/Sabre/File.php +++ b/apps/dav/lib/Connector/Sabre/File.php @@ -333,7 +333,17 @@ public function put($data) { } } - // since we skipped the view we need to scan and emit the hooks ourselves + // allow sync clients to send the mtime along in a header + $mtimeHeader = $this->request->getHeader('x-oc-mtime'); + $mtime = ($mtimeHeader !== '') ? $this->sanitizeMtime($mtimeHeader) : null; + + // Apply mtime to storage before the scanner picks it up + $nativeTouchSucceeded = false; + if ($mtime !== null) { + $nativeTouchSucceeded = $storage->touch($internalPath, $mtime); + } + + // Since we skipped the view we need to scan and emit the hooks ourselves $storage->getUpdater()->update($internalPath); try { @@ -342,19 +352,18 @@ public function put($data) { throw new FileLocked($e->getMessage(), $e->getCode(), $e); } - // allow sync clients to send the mtime along in a header - $mtimeHeader = $this->request->getHeader('x-oc-mtime'); - if ($mtimeHeader !== '') { - $mtime = $this->sanitizeMtime($mtimeHeader); - if ($this->fileView->touch($this->path, $mtime)) { + $fileInfoUpdate = [ + 'upload_time' => time(), + ]; + + if ($mtime !== null) { + if (!$nativeTouchSucceeded) { + // Native touch unsupported — write mtime directly to cache + $fileInfoUpdate['mtime'] = $mtime; $this->header('X-OC-MTime: accepted'); } } - $fileInfoUpdate = [ - 'upload_time' => time() - ]; - // allow sync clients to send the creation time along in a header $ctimeHeader = $this->request->getHeader('x-oc-ctime'); if ($ctimeHeader) { diff --git a/build/psalm-baseline.xml b/build/psalm-baseline.xml index 47edd7bbcc739..ca8b9ca526501 100644 --- a/build/psalm-baseline.xml +++ b/build/psalm-baseline.xml @@ -569,7 +569,6 @@ -