From 36d3018efb2abf80b971fa8c24b1ad9cffa1ef62 Mon Sep 17 00:00:00 2001 From: fyears <1142836+fyears@users.noreply.github.com> Date: Sun, 29 Sep 2024 10:09:49 +0800 Subject: [PATCH] fix ignore logic --- pro/src/sync.ts | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/pro/src/sync.ts b/pro/src/sync.ts index 6edca5a..d0b15f9 100644 --- a/pro/src/sync.ts +++ b/pro/src/sync.ts @@ -202,16 +202,19 @@ export const checkIsSkipItemOrNotByName = ( } } } - if (isInsideObsFolder(key, configDir) && finalIsIgnored === undefined) { - if (syncConfigDir) { + + // we have to check bookmarks.json firstly then check the whole .obsidian folder later + if (isBookmarksFile(key, configDir) && finalIsIgnored === undefined) { + if (syncBookmarks) { finalIsIgnored = false; } else { finalIsIgnored = true; } } - if (isBookmarksFile(key, configDir) && finalIsIgnored === undefined) { - if (syncBookmarks) { + // we have to check bookmarks.json firstly then check the whole .obsidian folder later + if (isInsideObsFolder(key, configDir) && finalIsIgnored === undefined) { + if (syncConfigDir) { finalIsIgnored = false; } else { finalIsIgnored = true; @@ -260,17 +263,9 @@ export const checkIsSkipItemOrNotByName = ( * | yes, also apply to children | explictly ignored | yes | yes | yes | */ export const getSkipItemsByList = ( - skipOrNotResults: Record, - ignorePaths: string[], - onlyAllowPaths: string[] + skipOrNotResults: Record ): string[] => { const allPotentialKeys = Object.keys(skipOrNotResults); - if ( - allPotentialKeys.length === 0 || - (ignorePaths.length === 0 && onlyAllowPaths.length === 0) - ) { - return []; - } // from short(shadow) to long(deep) , ascending const sortedKeys = allPotentialKeys.sort((k1, k2) => k1.length - k2.length); @@ -333,6 +328,7 @@ export const getSkipItemsByList = ( result.push(key); } } + console.debug(`finalIsIgnored list= ${JSON.stringify(result)}`); return result; }; @@ -499,11 +495,7 @@ const ensembleMixedEnties = async ( profiler?.insertSize("sizeof finalMappings", finalMappings); // we check the skipOrNotResults again! in case we adjust some paths! - const allReallySkipKeys = getSkipItemsByList( - skipOrNotResults, - ignorePaths, - onlyAllowPaths - ); + const allReallySkipKeys = getSkipItemsByList(skipOrNotResults); for (const key of allReallySkipKeys) { delete finalMappings[key]; }