Skip to content

Commit

Permalink
test: create backup for whole leveldb folder
Browse files Browse the repository at this point in the history
  • Loading branch information
OKendigelyan committed Dec 30, 2024
1 parent 89aa81e commit 0f8b3d3
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion apps/desktop/public/electron.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,25 @@ async function createBackupFromPrevDB() {
const backupPath = path.normalize(
path.join(app.getPath("userData"), "Local Storage", "backup_leveldb.json")
);
const dbBackupPath = path.normalize(
path.join(app.getPath("userData"), "Local Storage", "leveldb_backup")
);

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

// Copy the database to not lose original data
fs.cpSync(dbPath, dbBackupPath, { recursive: true });


if (fs.existsSync(backupPath)) {
log.info("Backup file already exists. Skipping migration.");
return;
}

const db = new Level(dbPath);
const db = new Level(dbBackupPath);

// Retry logic for opening the database
const maxRetries = 3;
Expand Down

0 comments on commit 0f8b3d3

Please sign in to comment.