feat: Correctly start backup before-write session files, b=no-bug, c=folders

This commit is contained in:
mr. m
2026-02-13 00:01:35 +01:00
parent 2eb09f092c
commit 5a26cb6601
2 changed files with 8 additions and 7 deletions

View File

@@ -98,6 +98,7 @@ zen-folder {
& svg {
filter: contrast(125%);
transform: translate(-1px, -1px);
:root:not([zen-sidebar-expanded]) & {
transition: transform 0.1s ease;

View File

@@ -84,14 +84,14 @@ export class nsZenSessionManager {
init() {
this.log("Initializing session manager");
let backupFile = null;
let backupTo = null;
if (SHOULD_BACKUP_FILE) {
backupFile = PathUtils.join(this.#backupFolderPath, FILE_NAME);
backupTo = PathUtils.join(this.#backupFolderPath, "recovery.baklz4");
}
this.#file = new JSONFile({
path: this.#storeFilePath,
compression: "lz4",
backupFile,
backupTo,
});
this.log("Session file path:", this.#file.path);
this.#deferredBackupTask = new lazy.DeferredTask(async () => {
@@ -526,12 +526,12 @@ export class nsZenSessionManager {
// Now we need to check if we have exceeded the maximum
// number of backups allowed, and delete the oldest ones
// if needed.
let prefix = PathUtils.join(backupFolder, "zen-sessions-");
let files = await IOUtils.getChildren(backupFolder);
files = files.filter((file) => file.startsWith("zen-sessions-")).sort();
files = files.filter((file) => file.startsWith(prefix)).sort();
for (let i = 0; i < files.length - lazy.gMaxSessionBackups; i++) {
const fileToDelete = PathUtils.join(backupFolder, files[i].name);
this.log(`Deleting old backup file ${files[i].name}`);
await IOUtils.remove(fileToDelete);
this.log(`Deleting old backup file ${files[i]}`);
await IOUtils.remove(files[i]);
}
} catch (e) {
console.error("ZenSessionManager: Failed to create session file backups", e);