Changed fs.cpSync to use recursive copying
This commit is contained in:
parent
3822ae9356
commit
15a8adb0b9
|
@ -680,7 +680,7 @@ router.post('/rename', jsonParser, async function (request, response) {
|
|||
|
||||
// Rename chats folder
|
||||
if (fs.existsSync(oldChatsPath) && !fs.existsSync(newChatsPath)) {
|
||||
fs.cpSync(oldChatsPath, newChatsPath);
|
||||
fs.cpSync(oldChatsPath, newChatsPath, { recursive: true });
|
||||
fs.rmSync(oldChatsPath, { recursive: true, force: true });
|
||||
}
|
||||
|
||||
|
|
12
src/users.js
12
src/users.js
|
@ -286,13 +286,21 @@ async function migrateUserData() {
|
|||
// Copy the file to the new location
|
||||
fs.cpSync(migration.old, migration.new, { force: true });
|
||||
// Move the file to the backup location
|
||||
fs.cpSync(migration.old, path.join(backupDirectory, path.basename(migration.old)));
|
||||
fs.cpSync(
|
||||
migration.old,
|
||||
path.join(backupDirectory, path.basename(migration.old)),
|
||||
{ recursive: true, force: true }
|
||||
);
|
||||
fs.rmSync(migration.old, { recursive: true, force: true });
|
||||
} else {
|
||||
// Copy the directory to the new location
|
||||
fs.cpSync(migration.old, migration.new, { recursive: true, force: true });
|
||||
// Move the directory to the backup location
|
||||
fs.cpSync(migration.old, path.join(backupDirectory, path.basename(migration.old)));
|
||||
fs.cpSync(
|
||||
migration.old,
|
||||
path.join(backupDirectory, path.basename(migration.old)),
|
||||
{ recursive: true, force: true }
|
||||
);
|
||||
fs.rmSync(migration.old, { recursive: true, force: true });
|
||||
}
|
||||
} catch (error) {
|
||||
|
|
Loading…
Reference in New Issue