auto clean sync plans
This commit is contained in:
+22
@@ -26,6 +26,7 @@ import {
|
||||
InternalDBs,
|
||||
insertLoggerOutputByVault,
|
||||
clearExpiredLoggerOutputRecords,
|
||||
clearExpiredSyncPlanRecords,
|
||||
} from "./localdb";
|
||||
import { RemoteClient } from "./remote";
|
||||
import {
|
||||
@@ -419,6 +420,9 @@ export default class RemotelySavePlugin extends Plugin {
|
||||
this.addOutputToDBIfSet();
|
||||
this.enableAutoClearOutputToDBHistIfSet();
|
||||
|
||||
// must AFTER preparing DB
|
||||
this.enableAutoClearSyncPlanHist();
|
||||
|
||||
this.syncStatus = "idle";
|
||||
|
||||
this.registerEvent(
|
||||
@@ -948,4 +952,22 @@ export default class RemotelySavePlugin extends Plugin {
|
||||
this.registerInterval(intervalID);
|
||||
});
|
||||
}
|
||||
|
||||
enableAutoClearSyncPlanHist() {
|
||||
const initClearSyncPlanHistAfterMilliseconds = 1000 * 45;
|
||||
const autoClearSyncPlanHistAfterMilliseconds = 1000 * 60 * 5;
|
||||
|
||||
this.app.workspace.onLayoutReady(() => {
|
||||
// init run
|
||||
window.setTimeout(() => {
|
||||
clearExpiredSyncPlanRecords(this.db);
|
||||
}, initClearSyncPlanHistAfterMilliseconds);
|
||||
|
||||
// scheduled run
|
||||
const intervalID = window.setInterval(() => {
|
||||
clearExpiredSyncPlanRecords(this.db);
|
||||
}, autoClearSyncPlanHistAfterMilliseconds);
|
||||
this.registerInterval(intervalID);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user