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
+7 -2
View File
@@ -204,8 +204,13 @@ export default class AnonymizedFile {
}); });
} }
const out = await this.repository.source?.getFileContent(this); const out = await this.repository.source?.getFileContent(this);
this.repository.model.isReseted = false; if (
await this.repository.updateStatus(RepositoryStatus.READY); !this.repository.model.isReseted ||
this.repository.status != RepositoryStatus.READY
) {
this.repository.model.isReseted = false;
await this.repository.updateStatus(RepositoryStatus.READY);
}
return out; return out;
} finally { } finally {
span.end(); span.end();
+2 -1
View File
@@ -18,7 +18,8 @@ export default class Conference {
*/ */
async updateStatus(status: ConferenceStatus, errorMessage?: string) { async updateStatus(status: ConferenceStatus, errorMessage?: string) {
this._data.status = status; this._data.status = status;
return this._data.save(); await this._data.save();
return;
} }
/** /**
+3 -3
View File
@@ -173,7 +173,7 @@ export default class PullRequest {
async countView() { async countView() {
this._model.lastView = new Date(); this._model.lastView = new Date();
this._model.pageView = (this._model.pageView || 0) + 1; 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.status = status;
this._model.statusDate = new Date(); this._model.statusDate = new Date();
this._model.statusMessage = statusMessage; 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.mergedDate = undefined;
this._model.pullRequest.state = "closed"; this._model.pullRequest.state = "closed";
this._model.pullRequest.draft = false; this._model.pullRequest.draft = false;
return Promise.all([this._model.save()]); await this._model.save();
} }
/** /**
+2 -2
View File
@@ -304,7 +304,7 @@ export default class Repository {
this._model.lastView = new Date(); this._model.lastView = new Date();
this._model.pageView = (this._model.pageView || 0) + 1; this._model.pageView = (this._model.pageView || 0) + 1;
if (!isConnected) return this.model; if (!isConnected) return this.model;
return this._model.save(); await this._model.save();
} finally { } finally {
span.end(); span.end();
} }
@@ -328,7 +328,7 @@ export default class Repository {
this._model.statusDate = new Date(); this._model.statusDate = new Date();
this._model.statusMessage = statusMessage; this._model.statusMessage = statusMessage;
if (!isConnected) return this.model; if (!isConnected) return this.model;
return this._model.save(); await this._model.save();
} finally { } finally {
span.end(); span.end();
} }
+2 -1
View File
@@ -48,7 +48,8 @@ router.get(
} }
// cache the file for 5min // cache the file for 5min
res.header("Cache-Control", "max-age=300"); res.header("Cache-Control", "max-age=300");
await Promise.all([repo.countView(), f.send(res)]); await repo.countView();
f.send(res);
} catch (error) { } catch (error) {
return handleError(error, res, req); return handleError(error, res, req);
} }