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:
parent
49286ec146
commit
0b287a831a
@ -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.
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user