feat: check repo status before update

This commit is contained in:
tdurieux
2024-04-11 15:25:45 +01:00
parent 05fa010349
commit 61c6a79949
3 changed files with 23 additions and 6 deletions
+16
View File
@@ -181,6 +181,7 @@ export default class Repository {
this._model.options.expirationDate
) {
if (this._model.options.expirationDate <= new Date()) {
this._model.status = RepositoryStatus.EXPIRED;
this.expire();
}
}
@@ -261,6 +262,21 @@ export default class Repository {
.getTracer("ano-file")
.startSpan("Repository.updateIfNeeded");
span.setAttribute("repoId", this.repoId);
if (
this._model.options.expirationMode !== "never" &&
this.status != RepositoryStatus.EXPIRED &&
this._model.options.expirationDate
) {
if (this._model.options.expirationDate <= new Date()) {
this._model.status = RepositoryStatus.EXPIRED;
await this.expire();
throw new AnonymousError("repository_expired", {
object: this,
httpStatus: 410,
});
}
}
const yesterday = new Date();
yesterday.setDate(yesterday.getDate() - 1);
if (