fix: properly await file deletion

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

View file

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