Skip to content

Commit a2eed98

Browse files
authored
Merge pull request #52686 from nextcloud/isNumericMtime
2 parents 7e9fc76 + 2d68644 commit a2eed98

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

apps/files_external/lib/Lib/Storage/Swift.php

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,6 @@ public function opendir(string $path) {
288288

289289
public function stat(string $path): array|false {
290290
$path = $this->normalizePath($path);
291-
292291
if ($path === '.') {
293292
$path = '';
294293
} elseif ($this->is_dir($path)) {
@@ -308,22 +307,23 @@ public function stat(string $path): array|false {
308307
return false;
309308
}
310309

311-
$dateTime = $object->lastModified ? \DateTime::createFromFormat(\DateTime::RFC1123, $object->lastModified) : false;
312-
$mtime = $dateTime ? $dateTime->getTimestamp() : null;
313-
$objectMetadata = $object->getMetadata();
314-
if (isset($objectMetadata['timestamp'])) {
315-
$mtime = $objectMetadata['timestamp'];
310+
$mtime = null;
311+
if (!empty($object->lastModified)) {
312+
$dateTime = \DateTime::createFromFormat(\DateTime::RFC1123, $object->lastModified);
313+
if ($dateTime !== false) {
314+
$mtime = $dateTime->getTimestamp();
315+
}
316316
}
317317

318-
if (!empty($mtime)) {
319-
$mtime = floor($mtime);
318+
if (is_numeric($object->getMetadata()['timestamp'] ?? null)) {
319+
$mtime = (float)$object->getMetadata()['timestamp'];
320320
}
321321

322-
$stat = [];
323-
$stat['size'] = (int)$object->contentLength;
324-
$stat['mtime'] = $mtime;
325-
$stat['atime'] = time();
326-
return $stat;
322+
return [
323+
'size' => (int)$object->contentLength,
324+
'mtime' => isset($mtime) ? (int)floor($mtime) : null,
325+
'atime' => time(),
326+
];
327327
}
328328

329329
public function filetype(string $path) {

0 commit comments

Comments
 (0)