From ce5b0cb3038cb37542e32a446d452ae111fbe38d Mon Sep 17 00:00:00 2001 From: antelle Date: Thu, 25 Apr 2019 18:17:37 +0200 Subject: [PATCH] copy the cookies file if it's not possible to move it --- desktop/app.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/desktop/app.js b/desktop/app.js index 6440eac0..a1639f58 100644 --- a/desktop/app.js +++ b/desktop/app.js @@ -422,8 +422,15 @@ function restorePreferences() { const newProfilePath = path.join(tempUserDataPath, newProfile.dir); if (fs.existsSync(path.join(oldProfilePath, 'Cookies'))) { fs.mkdirSync(newProfilePath); - fs.renameSync(path.join(oldProfilePath, 'Cookies'), - path.join(newProfilePath, 'Cookies')); + const cookiesFileSrc = path.join(oldProfilePath, 'Cookies'); + const cookiesFileDest = path.join(newProfilePath, 'Cookies'); + try { + fs.renameSync(cookiesFileSrc, cookiesFileDest); + } catch (e) { + try { + fs.copyFileSync(cookiesFileSrc, cookiesFileDest); + } catch (e) { } + } } } }