fix: properly await file deletion
Some checks failed
ci/woodpecker/push/lint-client Pipeline failed
ci/woodpecker/push/lint-backend Pipeline failed
ci/woodpecker/push/lint-foundkey-js Pipeline was successful
ci/woodpecker/push/build Pipeline was successful
ci/woodpecker/push/lint-sw Pipeline failed
ci/woodpecker/push/test Pipeline failed

This commit is contained in:
Johann150 2023-05-23 22:56:51 +02:00
parent f54fa0ad02
commit 79acdd7652
Signed by: Johann150
GPG key ID: 9EE6577A2A06F8F1

View file

@ -60,14 +60,14 @@ export async function deleteFileSync(file: DriveFile, isExpired = false): Promis
await Promise.all(promises); await Promise.all(promises);
} }
postProcess(file, isExpired); await postProcess(file, isExpired);
} }
async function postProcess(file: DriveFile, isExpired = false): Promise<void> { async function postProcess(file: DriveFile, isExpired = false): Promise<void> {
// Turn into a direct link after expiring a remote file. // Turn into a direct link after expiring a remote file.
if (isExpired && file.userHost != null && file.uri != null) { if (isExpired && file.userHost != null && file.uri != null) {
const id = uuid(); const id = uuid();
DriveFiles.update(file.id, { await DriveFiles.update(file.id, {
isLink: true, isLink: true,
url: file.uri, url: file.uri,
thumbnailUrl: null, thumbnailUrl: null,
@ -78,14 +78,14 @@ async function postProcess(file: DriveFile, isExpired = false): Promise<void> {
webpublicAccessKey: 'webpublic-' + id, webpublicAccessKey: 'webpublic-' + id,
}); });
} else { } else {
DriveFiles.delete(file.id); await DriveFiles.delete(file.id);
} }
// update statistics // update statistics
driveChart.update(file, false); await driveChart.update(file, false);
perUserDriveChart.update(file, false); await perUserDriveChart.update(file, false);
if (file.userHost != null) { if (file.userHost != null) {
instanceChart.updateDrive(file, false); await instanceChart.updateDrive(file, false);
} }
} }