From 35d05236a76042bdd052257214645a5257708a07 Mon Sep 17 00:00:00 2001 From: filesite Date: Thu, 31 Mar 2022 08:41:44 +0800 Subject: [PATCH] improve snapshot description file parse --- lib/DirScanner.php | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/lib/DirScanner.php b/lib/DirScanner.php index fa20ea6..775ee83 100644 --- a/lib/DirScanner.php +++ b/lib/DirScanner.php @@ -84,15 +84,16 @@ Class DirScanner { if (in_array($field, ['title', 'snapshot'])) { $content = preg_replace('/\s/', '', $content); if ($field == 'snapshot') { - $img_realpath = str_replace("{$pathinfo['filename']}.{$pathinfo['extension']}", $content, $realpath); - echo "img_realpath: ".$img_realpath."\n"; - $id = $this->getId($img_realpath); - $fp = fopen($img_realpath, 'r'); - $fstat = fstat($fp); - fclose($fp); - $img_pathinfo = pathinfo($img_realpath); - $extension = strtolower($img_pathinfo['extension']); - $content = $this->getFilePath( $id, $this->getDirectoryName($img_pathinfo['dirname'], $dirLevel), $img_pathinfo['filename'], $extension, $fstat['mtime'] ); + $img_realpath = "{$pathinfo['dirname']}/{$content}"; + if (file_exists($img_realpath)) { + $id = $this->getId($img_realpath); + $fp = fopen($img_realpath, 'r'); + $fstat = fstat($fp); + fclose($fp); + $img_pathinfo = pathinfo($img_realpath); + $extension = strtolower($img_pathinfo['extension']); + $content = $this->getFilePath( $id, $this->getDirectoryName($img_pathinfo['dirname'], $dirLevel), $img_pathinfo['filename'], $extension, $fstat['mtime'] ); + } } } $data[$field] = $content;