Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3357712
D4282.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D4282.diff
View Options
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
Details
Attached
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)
Attached To
Mode
D4282: [keyserver] Extract deleteBackup
Attached
Detach File
Event Timeline
Log In to Comment