mirror of
https://github.com/tdurieux/anonymous_github.git
synced 2026-08-15 00:10:44 +02:00
fix: only expire repositories that are ready
This commit is contained in:
+9
-10
@@ -152,11 +152,10 @@ export default class Repository {
|
|||||||
(f) => f.name == branch.name
|
(f) => f.name == branch.name
|
||||||
)[0].commit;
|
)[0].commit;
|
||||||
this._model.anonymizeDate = new Date();
|
this._model.anonymizeDate = new Date();
|
||||||
await this.updateStatus("preparing");
|
|
||||||
console.log(
|
console.log(
|
||||||
`${this._model.repoId} will be updated to ${this._model.source.commit}`
|
`${this._model.repoId} will be updated to ${this._model.source.commit}`
|
||||||
);
|
);
|
||||||
await this.resetSate();
|
await this.resetSate("preparing");
|
||||||
await this.anonymize();
|
await this.anonymize();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -191,7 +190,6 @@ export default class Repository {
|
|||||||
async updateStatus(status: RepositoryStatus, errorMessage?: string) {
|
async updateStatus(status: RepositoryStatus, errorMessage?: string) {
|
||||||
this._model.status = status;
|
this._model.status = status;
|
||||||
this._model.errorMessage = errorMessage;
|
this._model.errorMessage = errorMessage;
|
||||||
this._model.status = status;
|
|
||||||
await this._model.save();
|
await this._model.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -199,26 +197,27 @@ export default class Repository {
|
|||||||
* Expire the repository
|
* Expire the repository
|
||||||
*/
|
*/
|
||||||
async expire() {
|
async expire() {
|
||||||
await this.updateStatus("expired");
|
this.resetSate("expired");
|
||||||
await this.resetSate();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove the repository
|
* Remove the repository
|
||||||
*/
|
*/
|
||||||
async remove() {
|
async remove() {
|
||||||
await this.updateStatus("removed");
|
this.resetSate("removed");
|
||||||
await this.resetSate();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reset/delete the state of the repository
|
* Reset/delete the state of the repository
|
||||||
*/
|
*/
|
||||||
private async resetSate() {
|
private async resetSate(status?: RepositoryStatus) {
|
||||||
|
if (status) this._model.status = status;
|
||||||
this._model.size = 0;
|
this._model.size = 0;
|
||||||
this._model.originalFiles = null;
|
this._model.originalFiles = null;
|
||||||
await this._model.save();
|
return Promise.all([
|
||||||
await storage.rm(this._model.repoId + "/");
|
this._model.save(),
|
||||||
|
storage.rm(this._model.repoId + "/"),
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -116,6 +116,7 @@ export default class User {
|
|||||||
const promises = [];
|
const promises = [];
|
||||||
for (let repo of repositories) {
|
for (let repo of repositories) {
|
||||||
if (
|
if (
|
||||||
|
repo.status == "ready" &&
|
||||||
repo.options.expirationMode != "never" &&
|
repo.options.expirationMode != "never" &&
|
||||||
repo.options.expirationDate != null &&
|
repo.options.expirationDate != null &&
|
||||||
repo.options.expirationDate < new Date()
|
repo.options.expirationDate < new Date()
|
||||||
|
|||||||
Reference in New Issue
Block a user