修復跨盤不能復製文件問題
This commit is contained in:
9
index.js
9
index.js
@@ -25,11 +25,18 @@ async function main() {
|
||||
|
||||
Object.keys(objects).forEach(element => {
|
||||
let hash = objects[element].hash;
|
||||
let srcfilepath = join(srcpath, hash.substring(0, 2), hash);
|
||||
let distfilepath = join(distpath, element);
|
||||
|
||||
if (!fs.existsSync(distfilepath)) {
|
||||
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}`)
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user