From d0869e3e5ef84bee36e7ab33c39937e259f4c444 Mon Sep 17 00:00:00 2001 From: GP247 Date: Tue, 9 Sep 2025 05:52:14 +0700 Subject: [PATCH] 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. --- src/LfmItem.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/LfmItem.php b/src/LfmItem.php index e7f48747..3aeb0e13 100644 --- a/src/LfmItem.php +++ b/src/LfmItem.php @@ -110,7 +110,18 @@ public function size() public function time() { - return $this->lfm->lastModified(); + // Avoid requesting lastModified for directories on S3-like drivers + // because folders are virtual and may not have an object key. + if ($this->isDirectory()) { + return ''; + } + + try { + return $this->lfm->lastModified(); + } catch (\Throwable $e) { + // Gracefully degrade if backend cannot retrieve metadata + return ''; + } } public function thumbUrl()