mirror of
https://github.com/tdurieux/anonymous_github.git
synced 2026-05-16 06:49:09 +02:00
fix: check last status activity
This commit is contained in:
+14
-8
@@ -97,19 +97,22 @@ export default class Repository {
|
|||||||
check() {
|
check() {
|
||||||
if (
|
if (
|
||||||
this._model.options.expirationMode !== "never" &&
|
this._model.options.expirationMode !== "never" &&
|
||||||
this._model.status == "ready"
|
this.status == "ready"
|
||||||
) {
|
) {
|
||||||
if (this._model.options.expirationDate <= new Date()) {
|
if (this._model.options.expirationDate <= new Date()) {
|
||||||
this.expire();
|
this.expire();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (this._model.status == "expired") {
|
if (this.status == "expired") {
|
||||||
throw new AnonymousError("repository_expired", this);
|
throw new AnonymousError("repository_expired", this);
|
||||||
}
|
}
|
||||||
if (this._model.status == "removed") {
|
if (this.status == "removed") {
|
||||||
throw new AnonymousError("repository_expired", this);
|
throw new AnonymousError("repository_expired", this);
|
||||||
}
|
}
|
||||||
if (this._model.status == "download") {
|
const fiveMinuteAgo = new Date();
|
||||||
|
fiveMinuteAgo.setMinutes(fiveMinuteAgo.getMinutes() - 5);
|
||||||
|
|
||||||
|
if (this.status == "download" && this._model.statusDate > fiveMinuteAgo) {
|
||||||
throw new AnonymousError("repository_not_ready", this);
|
throw new AnonymousError("repository_not_ready", this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -137,7 +140,10 @@ export default class Repository {
|
|||||||
yesterday.setDate(yesterday.getDate() - 1);
|
yesterday.setDate(yesterday.getDate() - 1);
|
||||||
|
|
||||||
if (this._model.options.update && this._model.lastView < yesterday) {
|
if (this._model.options.update && this._model.lastView < yesterday) {
|
||||||
if (this._model.status == "download") {
|
|
||||||
|
const fiveMinuteAgo = new Date();
|
||||||
|
fiveMinuteAgo.setMinutes(fiveMinuteAgo.getMinutes() - 5);
|
||||||
|
if (this.status == "download" && this._model.statusDate > fiveMinuteAgo) {
|
||||||
throw new AnonymousError("repository_not_ready", this);
|
throw new AnonymousError("repository_not_ready", this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -182,7 +188,7 @@ export default class Repository {
|
|||||||
* @returns void
|
* @returns void
|
||||||
*/
|
*/
|
||||||
async anonymize() {
|
async anonymize() {
|
||||||
if (this._model.status == "ready") return;
|
if (this.status == "ready") return;
|
||||||
await this.updateStatus("preparing");
|
await this.updateStatus("preparing");
|
||||||
await this.files();
|
await this.files();
|
||||||
return this.updateStatus("ready");
|
return this.updateStatus("ready");
|
||||||
@@ -251,7 +257,7 @@ export default class Repository {
|
|||||||
*/
|
*/
|
||||||
file: number;
|
file: number;
|
||||||
}> {
|
}> {
|
||||||
if (this._model.status != "ready") return { storage: 0, file: 0 };
|
if (this.status != "ready") return { storage: 0, file: 0 };
|
||||||
if (this._model.size.file) return this._model.size;
|
if (this._model.size.file) return this._model.size;
|
||||||
function recursiveCount(files) {
|
function recursiveCount(files) {
|
||||||
const out = { storage: 0, file: 0 };
|
const out = { storage: 0, file: 0 };
|
||||||
@@ -314,7 +320,7 @@ export default class Repository {
|
|||||||
}
|
}
|
||||||
|
|
||||||
get size() {
|
get size() {
|
||||||
if (this._model.status != "ready") return { storage: 0, file: 0 };
|
if (this.status != "ready") return { storage: 0, file: 0 };
|
||||||
return this._model.size;
|
return this._model.size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user