This commit is contained in:
tianmo committed 2026-09-10 14:04:53 +08:00
1 parent 9635428f78
commit ef01cdd6ee
6 files changed
+172 -66

No files matched your search

+3 -3
View File
@@ -359,14 +359,14 @@ function collectSpineFiles(roots, validFolders) {
* 很短的缓存,下一轮轮询仍会重新扫描,因此既降低大文件夹导入开销,也不会漏掉
* 正在落盘的新文件。
*/
function collectSpineFilesCached(filePath, roots) {
function collectSpineFilesCached(filePath, roots, refresh) {
const libRoot = findLibraryRoot(filePath);
// Outside an Eagle library, sibling asset folders are independent search
// scopes. Sharing their parent as a cache key can return another skeleton.
const key = libRoot || JSON.stringify([...roots].sort());
const now = Date.now();
const cached = fileIndexCache.get(key);
if (cached && now - cached.time < 1500) return cached.files;
if (!refresh && cached && now - cached.time < 1500) return cached.files;
const files = collectSpineFiles(roots, null);
fileIndexCache.set(key, { time: now, files });
return files;
@@ -434,7 +434,7 @@ function discoverAssets(filePath, options) {
const allowedImportDelta = allowCrossBatch ? maxCrossBatchDeltaMs : 30000;
let files = collectSpineFiles(roots, validFolders);
if (strictStem) {
const allFiles = collectSpineFilesCached(filePath, roots);
const allFiles = collectSpineFilesCached(filePath, roots, options.refreshIndex);
if (allowCrossBatch && validFolders && validFolders.size) {
files = allFiles.filter((f) => foldersOfItem(f.fullPath).some((id) => validFolders.has(id)));
} else {