Page MenuHomePhabricator

D4282.diff
No OneTemporary

D4282.diff

diff --git a/keyserver/src/cron/backups.js b/keyserver/src/cron/backups.js
--- a/keyserver/src/cron/backups.js
+++ b/keyserver/src/cron/backups.js
@@ -194,19 +194,19 @@
}
async function deleteOldestBackup() {
- const [backupConfig, backupInfos] = await Promise.all([
- getBackupConfig(),
- getSortedBackupInfos(),
- ]);
-
- invariant(backupConfig, 'backupConfig should be non-null');
- if (backupInfos.length === 0) {
+ const sortedBackupInfos = await getSortedBackupInfos();
+ if (sortedBackupInfos.length === 0) {
throw new Error('no_backups_left');
}
+ const oldestFilename = sortedBackupInfos[0].filename;
+ await deleteBackup(oldestFilename);
+}
- const oldestFilename = backupInfos[0].filename;
+async function deleteBackup(filename: string) {
+ const backupConfig = await getBackupConfig();
+ invariant(backupConfig, 'backupConfig should be non-null');
try {
- await unlink(`${backupConfig.directory}/${oldestFilename}`);
+ await unlink(`${backupConfig.directory}/${filename}`);
} catch (e) {
// Check if it's already been deleted
if (e.code !== 'ENOENT') {

File Metadata

Mime Type
text/plain
Expires
Mon, Nov 25, 1:11 AM (19 h, 47 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2577882
Default Alt Text
D4282.diff (1 KB)

Event Timeline