yes lots of logging and fix

This commit is contained in:
fyears 2024-02-24 11:55:35 +08:00
parent e34b120a63
commit c512330d84
4 changed files with 23 additions and 13 deletions

View File

@ -50,6 +50,8 @@ export const getLocalEntityList = async (
} else {
throw Error(`unexpected ${entry}`);
}
local.push(r);
}
if (syncConfigDir) {

View File

@ -240,7 +240,7 @@ export default class RemotelySavePlugin extends Plugin {
() => self.saveSettings()
);
const remoteEntityList = await client.listAllFromRemote();
// log.debug(remoteEntityList);
log.debug(remoteEntityList);
if (this.settings.currLogLevel === "info") {
// pass
@ -269,7 +269,7 @@ export default class RemotelySavePlugin extends Plugin {
this.app.vault.configDir,
this.manifest.id
);
// log.info(localEntityList);
log.debug(localEntityList);
if (this.settings.currLogLevel === "info") {
// pass
@ -281,7 +281,7 @@ export default class RemotelySavePlugin extends Plugin {
this.db,
this.vaultRandomID
);
// log.info(prevSyncEntityList);
log.debug(prevSyncEntityList);
if (this.settings.currLogLevel === "info") {
// pass

View File

@ -76,17 +76,16 @@ export const getFolderLevels = (x: string, addEndingSlash: boolean = false) => {
export const mkdirpInVault = async (thePath: string, vault: Vault) => {
// log.info(thePath);
// as of 2020219,
// Obsidian can create the folder recursively
// but the path should not end with '/'
if (thePath === "/" || thePath === "") {
return;
const foldersToBuild = getFolderLevels(thePath);
// log.info(foldersToBuild);
for (const folder of foldersToBuild) {
const r = await vault.adapter.exists(folder);
// log.info(r);
if (!r) {
log.info(`mkdir ${folder}`);
await vault.adapter.mkdir(folder);
}
}
let thePathNoEnding = thePath.endsWith("/")
? thePath.slice(0, thePath.length - 1)
: thePath;
await vault.adapter.mkdir(thePathNoEnding);
};
/**

View File

@ -442,6 +442,8 @@ export const getSyncPlanInplace = async (
// folder
// folder doesn't worry about mtime and size, only check their existences
if (keptFolder.has(key)) {
// parent should also be kept
keptFolder.add(getParentFolder(key));
// should fill the missing part
if (local !== undefined && remote !== undefined) {
mixedEntry.decisionBranch = 101;
@ -731,7 +733,9 @@ const splitThreeStepsOnEntityMappings = (
val.decision === "folder_existed_remote" ||
val.decision === "folder_to_be_created"
) {
log.debug(`splitting folder: key=${key},val=${JSON.stringify(val)}`);
const level = atWhichLevel(key);
log.debug(`atWhichLevel: ${level}`);
if (folderCreationOps[level - 1] === undefined) {
folderCreationOps[level - 1] = [val];
} else {
@ -891,6 +895,11 @@ export const doActualSync = async (
log.debug(`concurrency === ${concurrency}`);
const { folderCreationOps, deletionOps, uploadDownloads, realTotalCount } =
splitThreeStepsOnEntityMappings(mixedEntityMappings);
log.debug(`folderCreationOps: ${JSON.stringify(folderCreationOps)}`);
log.debug(`deletionOps: ${JSON.stringify(deletionOps)}`);
log.debug(`uploadDownloads: ${JSON.stringify(uploadDownloads)}`);
log.debug(`realTotalCount: ${JSON.stringify(realTotalCount)}`);
const nested = [folderCreationOps, deletionOps, uploadDownloads];
const logTexts = [
`1. create all folders from shadowest to deepest, also check undefined decision`,