check if folder/file name is valid

This commit is contained in:
fyears
2024-09-01 16:15:42 +08:00
parent fccebb0594
commit e9b9cd97ac
3 changed files with 200 additions and 0 deletions
+17
View File
@@ -28,6 +28,7 @@ import {
} from "../../src/metadataOnRemote";
import {
atWhichLevel,
checkValidName,
getParentFolder,
isHiddenPath,
isSpecialFolderNameToSkip,
@@ -211,6 +212,13 @@ const ensembleMixedEnties = async (
continue;
}
const checkValidNameResult = checkValidName(key);
if (!checkValidNameResult.result) {
throw Error(
`your remote folder/file name is invalid: ${checkValidNameResult.reason}`
);
}
finalMappings[key] = {
key: key,
remote: remoteCopied,
@@ -280,6 +288,13 @@ const ensembleMixedEnties = async (
continue;
}
const checkValidNameResult = checkValidName(key);
if (!checkValidNameResult.result) {
throw Error(
`your local folder/file name is invalid: ${checkValidNameResult.reason}`
);
}
// TODO: abstraction leaking?
const localCopied = await fsEncrypt.encryptEntity(
copyEntityAndFixTimeFormat(local, serviceType)
@@ -920,6 +935,8 @@ const getSyncPlanInplace = async (
keptFolder.delete("/");
keptFolder.delete("");
if (keptFolder.size > 0) {
console.error(sortedKeys);
console.error(mixedEntityMappings);
throw Error(`unexpectedly keptFolder no decisions: ${[...keptFolder]}`);
}