ignore paths by regexgit add .
This commit is contained in:
+4
-1
@@ -85,7 +85,7 @@ const DEFAULT_SETTINGS: RemotelySavePluginSettings = {
|
||||
lang: "auto",
|
||||
logToDB: false,
|
||||
skipSizeLargerThan: -1,
|
||||
ignorePaths: [".obsidian/workspace.json", ".obsidian/workspace-mobile.json", ".obsidian/community-plugins.json"],
|
||||
ignorePaths: [],
|
||||
};
|
||||
|
||||
interface OAuth2Info {
|
||||
@@ -795,6 +795,9 @@ export default class RemotelySavePlugin extends Plugin {
|
||||
if (this.settings.s3.forcePathStyle === undefined) {
|
||||
this.settings.s3.forcePathStyle = false;
|
||||
}
|
||||
if (this.settings.ignorePaths === undefined) {
|
||||
this.settings.ignorePaths = [];
|
||||
}
|
||||
}
|
||||
|
||||
async checkIfPresetRulesFollowed() {
|
||||
|
||||
+6
-1
@@ -1599,13 +1599,18 @@ export class RemotelySaveSettingTab extends PluginSettingTab {
|
||||
new Setting(basicDiv)
|
||||
.setName(t("settings_ignorepaths"))
|
||||
.setDesc(t("settings_ignorepaths_desc"))
|
||||
.setClass("ignorepaths-settings")
|
||||
|
||||
.addTextArea((textArea) => {
|
||||
textArea
|
||||
.setValue(`${this.plugin.settings.ignorePaths.join("\n")}`)
|
||||
.onChange(async (value) => {
|
||||
this.plugin.settings.ignorePaths = value.split("\n");
|
||||
this.plugin.settings.ignorePaths = value.trim().split("\n");
|
||||
await this.plugin.saveSettings();
|
||||
});
|
||||
textArea.inputEl.rows = 10;
|
||||
|
||||
textArea.inputEl.addClass("ignorepaths-textarea");
|
||||
});
|
||||
|
||||
//////////////////////////////////////////////////
|
||||
|
||||
+52
-7
@@ -7,6 +7,7 @@ import {
|
||||
} from "obsidian";
|
||||
import AggregateError from "aggregate-error";
|
||||
import PQueue from "p-queue";
|
||||
import XRegExp from "xregexp";
|
||||
import type {
|
||||
RemoteItem,
|
||||
SyncTriggerSourceType,
|
||||
@@ -296,8 +297,12 @@ const isSkipItem = (
|
||||
configDir: string,
|
||||
ignorePaths: string[]
|
||||
) => {
|
||||
if (ignorePaths.includes(key)) {
|
||||
return true;
|
||||
if (ignorePaths !== undefined && ignorePaths.length > 0) {
|
||||
for (const r of ignorePaths) {
|
||||
if (XRegExp(r, "A").test(key)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (syncConfigDir && isInsideObsFolder(key, configDir)) {
|
||||
return false;
|
||||
@@ -327,7 +332,15 @@ const ensembleMixedStates = async (
|
||||
for (const r of remoteStates) {
|
||||
const key = r.key;
|
||||
|
||||
if (isSkipItem(key, syncConfigDir, syncUnderscoreItems, configDir, ignorePaths)) {
|
||||
if (
|
||||
isSkipItem(
|
||||
key,
|
||||
syncConfigDir,
|
||||
syncUnderscoreItems,
|
||||
configDir,
|
||||
ignorePaths
|
||||
)
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
results[key] = r;
|
||||
@@ -366,7 +379,15 @@ const ensembleMixedStates = async (
|
||||
throw Error(`unexpected ${entry}`);
|
||||
}
|
||||
|
||||
if (isSkipItem(key, syncConfigDir, syncUnderscoreItems, configDir, ignorePaths)) {
|
||||
if (
|
||||
isSkipItem(
|
||||
key,
|
||||
syncConfigDir,
|
||||
syncUnderscoreItems,
|
||||
configDir,
|
||||
ignorePaths
|
||||
)
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -400,7 +421,15 @@ const ensembleMixedStates = async (
|
||||
password === "" ? undefined : getSizeFromOrigToEnc(entry.size),
|
||||
};
|
||||
|
||||
if (isSkipItem(key, syncConfigDir, syncUnderscoreItems, configDir, ignorePaths)) {
|
||||
if (
|
||||
isSkipItem(
|
||||
key,
|
||||
syncConfigDir,
|
||||
syncUnderscoreItems,
|
||||
configDir,
|
||||
ignorePaths
|
||||
)
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -426,7 +455,15 @@ const ensembleMixedStates = async (
|
||||
deltimeRemoteFmt: unixTimeToStr(entry.actionWhen),
|
||||
} as FileOrFolderMixedState;
|
||||
|
||||
if (isSkipItem(key, syncConfigDir, syncUnderscoreItems, configDir, ignorePaths)) {
|
||||
if (
|
||||
isSkipItem(
|
||||
key,
|
||||
syncConfigDir,
|
||||
syncUnderscoreItems,
|
||||
configDir,
|
||||
ignorePaths
|
||||
)
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -454,7 +491,15 @@ const ensembleMixedStates = async (
|
||||
throw Error(`unexpected ${entry}`);
|
||||
}
|
||||
|
||||
if (isSkipItem(key, syncConfigDir, syncUnderscoreItems, configDir, ignorePaths)) {
|
||||
if (
|
||||
isSkipItem(
|
||||
key,
|
||||
syncConfigDir,
|
||||
syncUnderscoreItems,
|
||||
configDir,
|
||||
ignorePaths
|
||||
)
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user