Skip to content

Commit 0f8b3d3

Browse files
committed
test: create backup for whole leveldb folder
1 parent 89aa81e commit 0f8b3d3

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

apps/desktop/public/electron.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,18 +55,25 @@ async function createBackupFromPrevDB() {
5555
const backupPath = path.normalize(
5656
path.join(app.getPath("userData"), "Local Storage", "backup_leveldb.json")
5757
);
58+
const dbBackupPath = path.normalize(
59+
path.join(app.getPath("userData"), "Local Storage", "leveldb_backup")
60+
);
5861

5962
if (!fs.existsSync(dbPath)) {
6063
log.error("LevelDB database not found at path. Code:EM01", dbPath);
6164
return;
6265
}
6366

67+
// Copy the database to not lose original data
68+
fs.cpSync(dbPath, dbBackupPath, { recursive: true });
69+
70+
6471
if (fs.existsSync(backupPath)) {
6572
log.info("Backup file already exists. Skipping migration.");
6673
return;
6774
}
6875

69-
const db = new Level(dbPath);
76+
const db = new Level(dbBackupPath);
7077

7178
// Retry logic for opening the database
7279
const maxRetries = 3;

0 commit comments

Comments
 (0)