diff --git a/themes/beauty/controller/CommandController.php b/themes/beauty/controller/CommandController.php index 481a187..b6cdc38 100644 --- a/themes/beauty/controller/CommandController.php +++ b/themes/beauty/controller/CommandController.php @@ -180,6 +180,15 @@ eof; foreach ($scanResults as $id => $item) { $hadScanedDirs = Common::getCache($cacheKey); + if (!empty($item['filename'])) { + //保存所有文件到索引 + $this->updateAllFilesCache($item); + //更新年份、月份时间索引 + $this->updateDateIndex($item); + //更新没有拍摄时间的文件索引 + $this->updateNoOriginalCtimeFiles($item); + } + if ( !empty($item['filename']) && empty($item['original_ctime']) @@ -200,18 +209,8 @@ eof; $this->scanMediaFiles($item['realpath']); } - $scanIndex ++; - - if (!empty($item['filename'])) { - //保存所有文件到索引 - $this->updateAllFilesCache($item); - //更新年份、月份时间索引 - $this->updateDateIndex($item); - //更新没有拍摄时间的文件索引 - $this->updateNoOriginalCtimeFiles($item); - } - //更新扫描进度 + $scanIndex ++; $stats = $this->updateScanStats($dirpath, $scanTotal, $scanIndex); } @@ -264,7 +263,7 @@ eof; * {"y2024": {"m1": [id1, id2, ...], "m10": [id1, id2, ...]}} */ protected function updateDateIndex($file) { - $ctime = !empty($file['original_ctime']) ? $file['original_ctime'] : $file['fstat']['ctime']; + $ctime = !empty($file['original_ctime']) ? $file['original_ctime'] : min($file['fstat']['mtime'], $file['fstat']['ctime']); $cacheKey = $this->dateIndexCacheKey; $cacheData = Common::getCache($cacheKey);