Fix self-hosted update path collision in cmdUpdate

This commit is contained in:
thePR0M3TH3AN committed 2026-02-26 08:41:36 -05:00
1 parent 811f45b3af
commit 32d0f905a6
2 files changed
+47 -4

No files matched your search

+20 -4
View File
@@ -85,9 +85,16 @@ function getPaths(root, installDirName) {
* @param {string} dest - Destination directory path.
*/
function copyDir(src, dest) {
if (fs.existsSync(src)) {
fs.cpSync(src, dest, { recursive: true });
if (!fs.existsSync(src)) return false;
const normalizedSrc = path.resolve(src);
const normalizedDest = path.resolve(dest);
if (normalizedSrc === normalizedDest) {
return false;
}
fs.cpSync(src, dest, { recursive: true });
return true;
}
/**
@@ -149,8 +156,12 @@ function syncAppDirectories(torchDir, verb = 'Copied') {
const src = path.join(PKG_ROOT, dir);
const dest = path.join(torchDir, dir);
if (fs.existsSync(src)) {
copyDir(src, dest);
console.log(` ${verb} ${dir}/`);
const copied = copyDir(src, dest);
if (copied) {
console.log(` ${verb} ${dir}/`);
} else {
console.log(` Skipped ${dir}/ (source and destination are identical)`);
}
}
}
}
@@ -179,6 +190,11 @@ function syncAppFiles(torchDir, installDir, verb = 'Copied') {
}
}
if (path.resolve(src) === path.resolve(dest)) {
console.log(` Skipped ${file} (source and destination are identical)`);
continue;
}
fs.copyFileSync(src, dest);
console.log(` ${verb} ${file}`);
}