add protection!

This commit is contained in:
fyears
2024-03-17 18:10:37 +08:00
parent c828a341ba
commit 7ec0102c7a
7 changed files with 119 additions and 4 deletions
+22
View File
@@ -93,6 +93,7 @@ const DEFAULT_SETTINGS: RemotelySavePluginSettings = {
agreeToUseSyncV3: false,
conflictAction: "keep_newer",
howToCleanEmptyFolder: "skip",
protectModifyPercentage: 50,
};
interface OAuth2Info {
@@ -338,6 +339,24 @@ export default class RemotelySavePlugin extends Plugin {
this.settings.password,
this.settings.concurrency ?? 5,
(key: string) => self.trash(key),
this.settings.protectModifyPercentage ?? 50,
(
protectModifyPercentage: number,
realModifyDeleteCount: number,
allFilesCount: number
) => {
const percent = (
(100 * realModifyDeleteCount) /
allFilesCount
).toFixed(1);
const res = t("syncrun_abort_protectmodifypercentage", {
protectModifyPercentage,
realModifyDeleteCount,
allFilesCount,
percent,
});
return res;
},
(
realCounter: number,
realTotalCount: number,
@@ -866,6 +885,9 @@ export default class RemotelySavePlugin extends Plugin {
if (this.settings.howToCleanEmptyFolder === undefined) {
this.settings.howToCleanEmptyFolder = "skip";
}
if (this.settings.protectModifyPercentage === undefined) {
this.settings.protectModifyPercentage = 50;
}
await this.saveSettings();
}