From 24a8b78e6891e4138533f8a9664e2ada0e1869b1 Mon Sep 17 00:00:00 2001 From: filesite Date: Sun, 24 Nov 2024 21:58:42 +0800 Subject: [PATCH] add function to get create time of file stat --- plugins/Common.php | 4 ++++ themes/beauty/controller/CommandController.php | 2 +- themes/beauty/views/site/index.php | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/plugins/Common.php b/plugins/Common.php index 60c9398..31a324e 100644 --- a/plugins/Common.php +++ b/plugins/Common.php @@ -793,4 +793,8 @@ Class Common { return !empty(self::$cache[$key]) ? self::$cache[$key] : null; } + public static function getFileCreateTime($file) { + return !empty($file['fstat']['mtime']) && !empty($file['fstat']['ctime']) ? min($file['fstat']['mtime'], $file['fstat']['ctime']) : 0; + } + } \ No newline at end of file diff --git a/themes/beauty/controller/CommandController.php b/themes/beauty/controller/CommandController.php index b6cdc38..de8bbb8 100644 --- a/themes/beauty/controller/CommandController.php +++ b/themes/beauty/controller/CommandController.php @@ -263,7 +263,7 @@ eof; * {"y2024": {"m1": [id1, id2, ...], "m10": [id1, id2, ...]}} */ protected function updateDateIndex($file) { - $ctime = !empty($file['original_ctime']) ? $file['original_ctime'] : min($file['fstat']['mtime'], $file['fstat']['ctime']); + $ctime = !empty($file['original_ctime']) ? $file['original_ctime'] : Common::getFileCreateTime($file); $cacheKey = $this->dateIndexCacheKey; $cacheData = Common::getCache($cacheKey); diff --git a/themes/beauty/views/site/index.php b/themes/beauty/views/site/index.php index 246bd96..77599a7 100644 --- a/themes/beauty/views/site/index.php +++ b/themes/beauty/views/site/index.php @@ -355,7 +355,7 @@ eof; }else { $title = Common::getDateFromString($file['filename']); //根据文件名获取拍摄日期 if (empty($title) && !empty($file['fstat']['mtime']) && !empty($file['fstat']['ctime'])) { - $title = date('Y-m-d', min($file['fstat']['mtime'], $file['fstat']['ctime'])); + $title = date('Y-m-d', Common::getFileCreateTime($file)); } }