Changed fs.cpSync to use recursive copying

This commit is contained in:
Isaac McFadyen 2024-04-18 16:04:04 -04:00
parent 3822ae9356
commit 15a8adb0b9
No known key found for this signature in database
2 changed files with 11 additions and 3 deletions

View File

@ -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 });
}

View File

@ -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) {