0
0
mirror of https://github.com/sp-tarkov/server.git synced 2025-02-13 09:50:43 -05:00

Fixes bug in FileSystem copy method

Updates file copying logic to use relative paths to formulate final copy source and destination paths.
This commit is contained in:
Refringe 2025-01-10 14:17:37 -05:00
parent 49286ec146
commit 0b287a831a
Signed by: Refringe
SSH Key Fingerprint: SHA256:t865XsQpfTeqPRBMN2G6+N8wlDjkgUCZF3WGW6O9N/k
2 changed files with 10 additions and 8 deletions

View File

@ -40,13 +40,14 @@ export class FileSystem {
const tasks: Promise<void>[] = [];
for (const dirent of dirents) {
const srcItem = path.join(src, dirent.name);
const destItem = path.join(dest, dirent.name);
const srcPath = path.join(dirent.parentPath, dirent.name);
const srcPathRel = path.relative(src, srcPath);
const destPath = path.join(dest, srcPathRel);
if (!dirent.isDirectory()) {
tasks.push(this.copyFile(srcItem, destItem, extensionsWhitelist));
tasks.push(this.copyFile(srcPath, destPath, extensionsWhitelist));
} else {
tasks.push(fsExtra.ensureDir(destItem)); // Ensures that an empty directories are copied.
tasks.push(fsExtra.ensureDir(destPath)); // Ensures that an empty directories are copied.
}
}

View File

@ -40,13 +40,14 @@ export class FileSystemSync {
}
for (const dirent of dirents) {
const srcItem = path.join(src, dirent.name);
const destItem = path.join(dest, dirent.name);
const srcPath = path.join(dirent.parentPath, dirent.name);
const srcPathRel = path.relative(src, srcPath);
const destPath = path.join(dest, srcPathRel);
if (!dirent.isDirectory()) {
this.copyFile(srcItem, destItem, extensionsWhitelist);
this.copyFile(srcPath, destPath, extensionsWhitelist);
} else {
fsExtra.ensureDirSync(destItem); // Ensures that empty subdirectories are copied.
fsExtra.ensureDirSync(destPath); // Ensures that empty subdirectories are copied.
}
}
}