mirror of
https://github.com/tdurieux/anonymous_github.git
synced 2026-09-13 06:08:58 +02:00
Fix repository cleanup after removal and expiration (#782)
This commit is contained in:
@@ -331,11 +331,11 @@ export default class AnonymizedFile {
|
||||
});
|
||||
}
|
||||
const content = await this.repository.source?.getFileContent(this);
|
||||
if (
|
||||
!this.repository.model.isReseted ||
|
||||
this.repository.status != RepositoryStatus.READY
|
||||
) {
|
||||
this.repository.model.isReseted = false;
|
||||
const cacheWasReset = this.repository.model.isReseted;
|
||||
if (cacheWasReset) {
|
||||
await this.repository.markCachePresent();
|
||||
}
|
||||
if (cacheWasReset || this.repository.status != RepositoryStatus.READY) {
|
||||
await this.repository.updateStatus(RepositoryStatus.READY);
|
||||
}
|
||||
return content;
|
||||
|
||||
@@ -543,6 +543,20 @@ export default class Repository {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Record that repository content has been cached again after a reset.
|
||||
*/
|
||||
async markCachePresent() {
|
||||
if (!this.model.isReseted) return;
|
||||
this.model.isReseted = false;
|
||||
if (isConnected) {
|
||||
await AnonymizedRepositoryModel.updateOne(
|
||||
{ _id: this._model._id },
|
||||
{ $set: { isReseted: false } }
|
||||
).exec();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Compute the size of the repository in term of storage and number of files.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user