diff --git a/src/AnonymizedFile.ts b/src/AnonymizedFile.ts index d97090e..28d2579 100644 --- a/src/AnonymizedFile.ts +++ b/src/AnonymizedFile.ts @@ -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(); diff --git a/src/Conference.ts b/src/Conference.ts index b07c03e..3d654c9 100644 --- a/src/Conference.ts +++ b/src/Conference.ts @@ -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; } /** diff --git a/src/PullRequest.ts b/src/PullRequest.ts index 42419e6..0bef31e 100644 --- a/src/PullRequest.ts +++ b/src/PullRequest.ts @@ -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(); } /** diff --git a/src/Repository.ts b/src/Repository.ts index e3656bf..9f03f07 100644 --- a/src/Repository.ts +++ b/src/Repository.ts @@ -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(); } diff --git a/src/routes/file.ts b/src/routes/file.ts index 36cfd1b..1f877f0 100644 --- a/src/routes/file.ts +++ b/src/routes/file.ts @@ -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); }