Skip to content

Commit d0869e3

Browse files
authored
Update LfmItem.php
Fix the error "Unable to retrieve the last_modified for file at location: file/your-sub-directory". This error appears when the main directory on S3 is scanning for files that have sub-directories inside.
1 parent 9091f98 commit d0869e3

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/LfmItem.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,18 @@ public function size()
110110

111111
public function time()
112112
{
113-
return $this->lfm->lastModified();
113+
// Avoid requesting lastModified for directories on S3-like drivers
114+
// because folders are virtual and may not have an object key.
115+
if ($this->isDirectory()) {
116+
return '';
117+
}
118+
119+
try {
120+
return $this->lfm->lastModified();
121+
} catch (\Throwable $e) {
122+
// Gracefully degrade if backend cannot retrieve metadata
123+
return '';
124+
}
114125
}
115126

116127
public function thumbUrl()

0 commit comments

Comments
 (0)