optimize folder

This commit is contained in:
fyears 2022-03-11 23:21:38 +08:00
parent 832b7e92f9
commit 2d9610cd92

View File

@ -540,39 +540,34 @@ const assignOperationToFolderInplace = async (
// if it was created after deletion, we should keep it as is // if it was created after deletion, we should keep it as is
if (requireApiVersion(API_VER_STAT_FOLDER)) { if (requireApiVersion(API_VER_STAT_FOLDER)) {
if (r.existLocal) { if (r.existLocal) {
try { const { ctime, mtime } = await vault.adapter.stat(r.key);
const { ctime, mtime } = await vault.adapter.stat(r.key); const cmtime = Math.max(ctime, mtime);
const cmtime = Math.max(ctime, mtime); if (cmtime > 0 && cmtime >= deltimeLocal && cmtime >= deltimeRemote) {
if ( keptFolder.add(getParentFolder(r.key));
cmtime > 0 && if (r.existLocal && r.existRemote) {
cmtime >= deltimeLocal && r.decision = "skipFolder";
cmtime >= deltimeRemote r.decisionBranch = 14;
) { } else if (r.existLocal || r.existRemote) {
keptFolder.add(getParentFolder(r.key)); r.decision = "createFolder";
if (r.existLocal && r.existRemote) { r.decisionBranch = 15;
r.decision = "skipFolder"; } else {
r.decisionBranch = 14; throw Error(
} else if (r.existLocal || r.existRemote) { `Error: Folder ${r.key} doesn't exist locally and remotely but is marked must be kept. Abort.`
r.decision = "createFolder"; );
r.decisionBranch = 15;
} else {
throw Error(
`Error: Folder ${r.key} doesn't exist locally and remotely but is marked must be kept. Abort.`
);
}
} }
} catch (error) {
// pass
} }
} }
} }
if (deltimeLocal > 0 && deltimeLocal > deltimeRemote) { if (r.decision === undefined) {
r.decision = "uploadLocalDelHistToRemoteFolder"; // not yet decided by the above reason
r.decisionBranch = 8; if (deltimeLocal > 0 && deltimeLocal > deltimeRemote) {
} else { r.decision = "uploadLocalDelHistToRemoteFolder";
r.decision = "keepRemoteDelHistFolder"; r.decisionBranch = 8;
r.decisionBranch = 9; } else {
r.decision = "keepRemoteDelHistFolder";
r.decisionBranch = 9;
}
} }
} else { } else {
// it does not have any deletion commands // it does not have any deletion commands