insert dry run into plan records

This commit is contained in:
fyears 2022-04-18 00:22:00 +08:00
parent 6fce079481
commit 13537d1481
3 changed files with 15 additions and 9 deletions

View File

@ -165,3 +165,5 @@ export const DEFAULT_DEBUG_FOLDER = "_debug_remotely_save/";
export const DEFAULT_SYNC_PLANS_HISTORY_FILE_PREFIX = export const DEFAULT_SYNC_PLANS_HISTORY_FILE_PREFIX =
"sync_plans_hist_exported_on_"; "sync_plans_hist_exported_on_";
export const DEFAULT_LOG_HISTORY_FILE_PREFIX = "log_hist_exported_on_"; export const DEFAULT_LOG_HISTORY_FILE_PREFIX = "log_hist_exported_on_";
export type SyncTriggerSourceType = "manual" | "auto" | "dry" | "autoOnceInit";

View File

@ -9,7 +9,10 @@ import {
} from "obsidian"; } from "obsidian";
import cloneDeep from "lodash/cloneDeep"; import cloneDeep from "lodash/cloneDeep";
import { createElement, RotateCcw, RefreshCcw, FileText } from "lucide"; import { createElement, RotateCcw, RefreshCcw, FileText } from "lucide";
import type { RemotelySavePluginSettings } from "./baseTypes"; import type {
RemotelySavePluginSettings,
SyncTriggerSourceType,
} from "./baseTypes";
import { import {
COMMAND_CALLBACK, COMMAND_CALLBACK,
COMMAND_CALLBACK_ONEDRIVE, COMMAND_CALLBACK_ONEDRIVE,
@ -89,8 +92,6 @@ interface OAuth2Info {
revokeAuthSetting?: Setting; revokeAuthSetting?: Setting;
} }
type SyncTriggerSourceType = "manual" | "auto" | "dry" | "autoOnceInit";
const iconNameSyncWait = `remotely-save-sync-wait`; const iconNameSyncWait = `remotely-save-sync-wait`;
const iconNameSyncRunning = `remotely-save-sync-running`; const iconNameSyncRunning = `remotely-save-sync-running`;
const iconNameLogs = `remotely-save-logs`; const iconNameLogs = `remotely-save-logs`;
@ -286,6 +287,7 @@ export default class RemotelySavePlugin extends Plugin {
origMetadataOnRemote.deletions, origMetadataOnRemote.deletions,
localHistory, localHistory,
client.serviceType, client.serviceType,
triggerSource,
this.app.vault, this.app.vault,
this.settings.syncConfigDir, this.settings.syncConfigDir,
this.app.vault.configDir, this.app.vault.configDir,
@ -293,9 +295,7 @@ export default class RemotelySavePlugin extends Plugin {
this.settings.password this.settings.password
); );
log.info(plan.mixedStates); // for debugging log.info(plan.mixedStates); // for debugging
if (triggerSource !== "dry") {
await insertSyncPlanRecordByVault(this.db, plan, this.vaultRandomID); await insertSyncPlanRecordByVault(this.db, plan, this.vaultRandomID);
}
// The operations above are almost read only and kind of safe. // The operations above are almost read only and kind of safe.
// The operations below begins to write or delete (!!!) something. // The operations below begins to write or delete (!!!) something.

View File

@ -7,13 +7,14 @@ import {
} from "obsidian"; } from "obsidian";
import AggregateError from "aggregate-error"; import AggregateError from "aggregate-error";
import PQueue from "p-queue"; import PQueue from "p-queue";
import { import type {
RemoteItem, RemoteItem,
SUPPORTED_SERVICES_TYPE, SyncTriggerSourceType,
DecisionType, DecisionType,
FileOrFolderMixedState, FileOrFolderMixedState,
API_VER_STAT_FOLDER, SUPPORTED_SERVICES_TYPE,
} from "./baseTypes"; } from "./baseTypes";
import { API_VER_STAT_FOLDER } from "./baseTypes";
import { import {
decryptBase32ToString, decryptBase32ToString,
decryptBase64urlToString, decryptBase64urlToString,
@ -65,6 +66,7 @@ export type SyncStatusType =
export interface SyncPlanType { export interface SyncPlanType {
ts: number; ts: number;
tsFmt?: string; tsFmt?: string;
syncTriggerSource?: SyncTriggerSourceType;
remoteType: SUPPORTED_SERVICES_TYPE; remoteType: SUPPORTED_SERVICES_TYPE;
mixedStates: Record<string, FileOrFolderMixedState>; mixedStates: Record<string, FileOrFolderMixedState>;
} }
@ -752,6 +754,7 @@ export const getSyncPlan = async (
remoteDeleteHistory: DeletionOnRemote[], remoteDeleteHistory: DeletionOnRemote[],
localFileHistory: FileFolderHistoryRecord[], localFileHistory: FileFolderHistoryRecord[],
remoteType: SUPPORTED_SERVICES_TYPE, remoteType: SUPPORTED_SERVICES_TYPE,
triggerSource: SyncTriggerSourceType,
vault: Vault, vault: Vault,
syncConfigDir: boolean, syncConfigDir: boolean,
configDir: string, configDir: string,
@ -824,6 +827,7 @@ export const getSyncPlan = async (
ts: currTs, ts: currTs,
tsFmt: currTsFmt, tsFmt: currTsFmt,
remoteType: remoteType, remoteType: remoteType,
syncTriggerSource: triggerSource,
mixedStates: mixedStates, mixedStates: mixedStates,
} as SyncPlanType; } as SyncPlanType;
return { return {