修復跨盤不能復製文件問題

This commit is contained in:
WongXX 2024-05-26 02:32:12 +08:00
parent c9ad4adfcc
commit 2bb76be945

View File

@ -25,11 +25,18 @@ async function main() {
Object.keys(objects).forEach(element => { Object.keys(objects).forEach(element => {
let hash = objects[element].hash; let hash = objects[element].hash;
let srcfilepath = join(srcpath, hash.substring(0, 2), hash);
let distfilepath = join(distpath, element); let distfilepath = join(distpath, element);
if (!fs.existsSync(distfilepath)) { if (!fs.existsSync(distfilepath)) {
fs.mkdirSync(dirname(distfilepath), { recursive: true }); fs.mkdirSync(dirname(distfilepath), { recursive: true });
} }
fs.renameSync(join(srcpath, hash.substring(0, 2), hash), distfilepath);
if (fs.existsSync(srcfilepath)) {
fs.copyFileSync(srcfilepath, distfilepath);
} else {
console.log(`文件不存在:${srcfilepath}`)
}
}); });
} }