correctly mkdir

This commit is contained in:
fyears 2024-04-24 03:08:51 +08:00
parent 86e0521dfc
commit b62163b1d1
2 changed files with 6 additions and 2 deletions

View File

@ -126,6 +126,7 @@ export class FakeFsLocal extends FakeFs {
}
async mkdir(key: string, mtime?: number, ctime?: number): Promise<Entity> {
// console.debug(`mkdir: ${key}`);
await mkdirpInVault(key, this.vault);
return await this.stat(key);
}

View File

@ -941,6 +941,7 @@ async function copyFile(
left: FakeFs,
right: FakeFs
): Promise<Entity> {
// console.debug(`copyFile: key=${key}, left=${left.kind}, right=${right.kind}`);
if (key.endsWith("/")) {
throw Error(`should not call ${key} in copyFile`);
}
@ -961,6 +962,7 @@ async function copyFile(
throw Error(`error copying ${left.kind}=>${right.kind}, no mtimeCli`);
}
// console.debug(`copyFile: about to start right.writeFile`);
return await right.writeFile(
key,
content,
@ -1060,8 +1062,9 @@ const dispatchOperationToActualV3 = async (
r.decision === "conflict_modified_then_keep_remote" ||
r.decision === "folder_existed_remote_then_also_create_local"
) {
await fsLocal.mkdir(r.key);
if (!r.key.endsWith("/")) {
if (r.key.endsWith("/")) {
await fsLocal.mkdir(r.key);
} else {
await copyFile(r.key, fsEncrypt, fsLocal);
}
await upsertPrevSyncRecordByVaultAndProfile(