add ignorePaths setting
This commit is contained in:
parent
81c79ab848
commit
79a0b9f44d
@ -86,6 +86,7 @@ export interface RemotelySavePluginSettings {
|
|||||||
lang?: LangTypeAndAuto;
|
lang?: LangTypeAndAuto;
|
||||||
logToDB?: boolean;
|
logToDB?: boolean;
|
||||||
skipSizeLargerThan?: number;
|
skipSizeLargerThan?: number;
|
||||||
|
ignorePaths?: string[];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated
|
* @deprecated
|
||||||
|
|||||||
@ -1 +1 @@
|
|||||||
Subproject commit 42eab5d544961f4c7830c63ba9559375437340c0
|
Subproject commit 0b961f4865d11e3c78d74776b8d0eb2d642aa505
|
||||||
@ -85,6 +85,7 @@ const DEFAULT_SETTINGS: RemotelySavePluginSettings = {
|
|||||||
lang: "auto",
|
lang: "auto",
|
||||||
logToDB: false,
|
logToDB: false,
|
||||||
skipSizeLargerThan: -1,
|
skipSizeLargerThan: -1,
|
||||||
|
ignorePaths: [".obsidian/workspace.json", ".obsidian/workspace-mobile.json", ".obsidian/community-plugins.json"],
|
||||||
};
|
};
|
||||||
|
|
||||||
interface OAuth2Info {
|
interface OAuth2Info {
|
||||||
@ -296,6 +297,7 @@ export default class RemotelySavePlugin extends Plugin {
|
|||||||
this.app.vault.configDir,
|
this.app.vault.configDir,
|
||||||
this.settings.syncUnderscoreItems,
|
this.settings.syncUnderscoreItems,
|
||||||
this.settings.skipSizeLargerThan,
|
this.settings.skipSizeLargerThan,
|
||||||
|
this.settings.ignorePaths,
|
||||||
this.settings.password
|
this.settings.password
|
||||||
);
|
);
|
||||||
log.info(plan.mixedStates); // for debugging
|
log.info(plan.mixedStates); // for debugging
|
||||||
|
|||||||
@ -1596,6 +1596,18 @@ export class RemotelySaveSettingTab extends PluginSettingTab {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
new Setting(basicDiv)
|
||||||
|
.setName(t("settings_ignorepaths"))
|
||||||
|
.setDesc(t("settings_ignorepaths_desc"))
|
||||||
|
.addTextArea((textArea) => {
|
||||||
|
textArea
|
||||||
|
.setValue(`${this.plugin.settings.ignorePaths.join("\n")}`)
|
||||||
|
.onChange(async (value) => {
|
||||||
|
this.plugin.settings.ignorePaths = value.split("\n");
|
||||||
|
await this.plugin.saveSettings();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
//////////////////////////////////////////////////
|
//////////////////////////////////////////////////
|
||||||
// below for advanced settings
|
// below for advanced settings
|
||||||
//////////////////////////////////////////////////
|
//////////////////////////////////////////////////
|
||||||
|
|||||||
22
src/sync.ts
22
src/sync.ts
@ -293,8 +293,12 @@ const isSkipItem = (
|
|||||||
key: string,
|
key: string,
|
||||||
syncConfigDir: boolean,
|
syncConfigDir: boolean,
|
||||||
syncUnderscoreItems: boolean,
|
syncUnderscoreItems: boolean,
|
||||||
configDir: string
|
configDir: string,
|
||||||
|
ignorePaths: string[]
|
||||||
) => {
|
) => {
|
||||||
|
if (ignorePaths.includes(key)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
if (syncConfigDir && isInsideObsFolder(key, configDir)) {
|
if (syncConfigDir && isInsideObsFolder(key, configDir)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -315,6 +319,7 @@ const ensembleMixedStates = async (
|
|||||||
syncConfigDir: boolean,
|
syncConfigDir: boolean,
|
||||||
configDir: string,
|
configDir: string,
|
||||||
syncUnderscoreItems: boolean,
|
syncUnderscoreItems: boolean,
|
||||||
|
ignorePaths: string[],
|
||||||
password: string
|
password: string
|
||||||
) => {
|
) => {
|
||||||
const results = {} as Record<string, FileOrFolderMixedState>;
|
const results = {} as Record<string, FileOrFolderMixedState>;
|
||||||
@ -322,7 +327,7 @@ const ensembleMixedStates = async (
|
|||||||
for (const r of remoteStates) {
|
for (const r of remoteStates) {
|
||||||
const key = r.key;
|
const key = r.key;
|
||||||
|
|
||||||
if (isSkipItem(key, syncConfigDir, syncUnderscoreItems, configDir)) {
|
if (isSkipItem(key, syncConfigDir, syncUnderscoreItems, configDir, ignorePaths)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
results[key] = r;
|
results[key] = r;
|
||||||
@ -361,7 +366,7 @@ const ensembleMixedStates = async (
|
|||||||
throw Error(`unexpected ${entry}`);
|
throw Error(`unexpected ${entry}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isSkipItem(key, syncConfigDir, syncUnderscoreItems, configDir)) {
|
if (isSkipItem(key, syncConfigDir, syncUnderscoreItems, configDir, ignorePaths)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -395,6 +400,10 @@ const ensembleMixedStates = async (
|
|||||||
password === "" ? undefined : getSizeFromOrigToEnc(entry.size),
|
password === "" ? undefined : getSizeFromOrigToEnc(entry.size),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (isSkipItem(key, syncConfigDir, syncUnderscoreItems, configDir, ignorePaths)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (results.hasOwnProperty(key)) {
|
if (results.hasOwnProperty(key)) {
|
||||||
results[key].key = r.key;
|
results[key].key = r.key;
|
||||||
results[key].existLocal = r.existLocal;
|
results[key].existLocal = r.existLocal;
|
||||||
@ -417,7 +426,7 @@ const ensembleMixedStates = async (
|
|||||||
deltimeRemoteFmt: unixTimeToStr(entry.actionWhen),
|
deltimeRemoteFmt: unixTimeToStr(entry.actionWhen),
|
||||||
} as FileOrFolderMixedState;
|
} as FileOrFolderMixedState;
|
||||||
|
|
||||||
if (isSkipItem(key, syncConfigDir, syncUnderscoreItems, configDir)) {
|
if (isSkipItem(key, syncConfigDir, syncUnderscoreItems, configDir, ignorePaths)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -445,7 +454,7 @@ const ensembleMixedStates = async (
|
|||||||
throw Error(`unexpected ${entry}`);
|
throw Error(`unexpected ${entry}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isSkipItem(key, syncConfigDir, syncUnderscoreItems, configDir)) {
|
if (isSkipItem(key, syncConfigDir, syncUnderscoreItems, configDir, ignorePaths)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -967,6 +976,7 @@ export const getSyncPlan = async (
|
|||||||
configDir: string,
|
configDir: string,
|
||||||
syncUnderscoreItems: boolean,
|
syncUnderscoreItems: boolean,
|
||||||
skipSizeLargerThan: number,
|
skipSizeLargerThan: number,
|
||||||
|
ignorePaths: string[],
|
||||||
password: string = ""
|
password: string = ""
|
||||||
) => {
|
) => {
|
||||||
const mixedStates = await ensembleMixedStates(
|
const mixedStates = await ensembleMixedStates(
|
||||||
@ -978,8 +988,10 @@ export const getSyncPlan = async (
|
|||||||
syncConfigDir,
|
syncConfigDir,
|
||||||
configDir,
|
configDir,
|
||||||
syncUnderscoreItems,
|
syncUnderscoreItems,
|
||||||
|
ignorePaths,
|
||||||
password
|
password
|
||||||
);
|
);
|
||||||
|
console.table(mixedStates)
|
||||||
|
|
||||||
const sortedKeys = Object.keys(mixedStates).sort(
|
const sortedKeys = Object.keys(mixedStates).sort(
|
||||||
(k1, k2) => k2.length - k1.length
|
(k1, k2) => k2.length - k1.length
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user