-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Store only latest update sequence per project in backups info file; a…
…djust backup file names
- Loading branch information
Showing
11 changed files
with
351 additions
and
345 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 44 additions & 4 deletions
48
desktop/src/app/services/backup/auto-backup/backup-file-name-utils.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
desktop/src/app/services/backup/auto-backup/get-existing-backups.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { Backup } from '../model/backup'; | ||
import { BackupsMap } from '../model/backups-map'; | ||
import { parseBackupFileName } from './backup-file-name-utils'; | ||
|
||
const fs = require('fs'); | ||
|
||
|
||
export function getExistingBackups(backupDirectoryPath: string): BackupsMap { | ||
|
||
const fileNames: string[] = fs.readdirSync(backupDirectoryPath); | ||
|
||
const existingBackups: BackupsMap = fileNames.reduce((result, fileName) => { | ||
const { project, creationDate } = parseBackupFileName(fileName) ?? {}; | ||
if (project && creationDate) { | ||
if (!result[project]) result[project] = []; | ||
result[project].push({ fileName, creationDate }); | ||
} | ||
return result; | ||
}, {}); | ||
|
||
sortBackups(existingBackups); | ||
|
||
return existingBackups; | ||
} | ||
|
||
|
||
function sortBackups(backups: BackupsMap) { | ||
|
||
Object.values(backups).forEach(projectBackups => { | ||
projectBackups.sort((backup1, backup2) => { | ||
return backup1.creationDate.getTime() - backup2.creationDate.getTime(); | ||
}); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
export interface Backup { | ||
|
||
fileName: string; | ||
updateSequence: number; | ||
creationDate: Date; | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,4 @@ | ||
import { Backup } from './backup'; | ||
|
||
|
||
export interface BackupsInfo { | ||
|
||
backups: { [project: string]: Array<Backup> }; | ||
lastUpdateSequence: { [project: string]: number }; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { Backup } from './backup'; | ||
|
||
export type BackupsMap = { [project: string]: Array<Backup> }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.