fix: add missing await

This commit is contained in:
tdurieux
2024-04-01 16:03:31 +01:00
parent 4881719160
commit 8a9d2d8395
5 changed files with 16 additions and 9 deletions

View File

@@ -204,8 +204,13 @@ export default class AnonymizedFile {
});
}
const out = await this.repository.source?.getFileContent(this);
this.repository.model.isReseted = false;
await this.repository.updateStatus(RepositoryStatus.READY);
if (
!this.repository.model.isReseted ||
this.repository.status != RepositoryStatus.READY
) {
this.repository.model.isReseted = false;
await this.repository.updateStatus(RepositoryStatus.READY);
}
return out;
} finally {
span.end();

View File

@@ -18,7 +18,8 @@ export default class Conference {
*/
async updateStatus(status: ConferenceStatus, errorMessage?: string) {
this._data.status = status;
return this._data.save();
await this._data.save();
return;
}
/**

View File

@@ -173,7 +173,7 @@ export default class PullRequest {
async countView() {
this._model.lastView = new Date();
this._model.pageView = (this._model.pageView || 0) + 1;
return this._model.save();
await this._model.save();
}
/**
@@ -185,7 +185,7 @@ export default class PullRequest {
this._model.status = status;
this._model.statusDate = new Date();
this._model.statusMessage = statusMessage;
return this._model.save();
await this._model.save();
}
/**
@@ -223,7 +223,7 @@ export default class PullRequest {
this._model.pullRequest.mergedDate = undefined;
this._model.pullRequest.state = "closed";
this._model.pullRequest.draft = false;
return Promise.all([this._model.save()]);
await this._model.save();
}
/**

View File

@@ -304,7 +304,7 @@ export default class Repository {
this._model.lastView = new Date();
this._model.pageView = (this._model.pageView || 0) + 1;
if (!isConnected) return this.model;
return this._model.save();
await this._model.save();
} finally {
span.end();
}
@@ -328,7 +328,7 @@ export default class Repository {
this._model.statusDate = new Date();
this._model.statusMessage = statusMessage;
if (!isConnected) return this.model;
return this._model.save();
await this._model.save();
} finally {
span.end();
}

View File

@@ -48,7 +48,8 @@ router.get(
}
// cache the file for 5min
res.header("Cache-Control", "max-age=300");
await Promise.all([repo.countView(), f.send(res)]);
await repo.countView();
f.send(res);
} catch (error) {
return handleError(error, res, req);
}