mirror of
https://github.com/tdurieux/anonymous_github.git
synced 2026-02-12 18:32:44 +00:00
fix: protect against double save
This commit is contained in:
@@ -10,6 +10,7 @@ import GitHubBase from "./GitHubBase";
|
||||
import AnonymizedFile from "../AnonymizedFile";
|
||||
import { RepositoryStatus, SourceBase } from "../types";
|
||||
import AnonymousError from "../AnonymousError";
|
||||
import { tryCatch } from "bullmq";
|
||||
|
||||
export default class GitHubDownload extends GitHubBase implements SourceBase {
|
||||
constructor(
|
||||
@@ -91,13 +92,13 @@ export default class GitHubDownload extends GitHubBase implements SourceBase {
|
||||
|
||||
const that = this;
|
||||
async function updateProgress() {
|
||||
if (progress && that.repository.status == RepositoryStatus.DOWNLOAD) {
|
||||
await that.repository.updateStatus(
|
||||
that.repository.status,
|
||||
progress.transferred.toString()
|
||||
);
|
||||
}
|
||||
if (inDownload) {
|
||||
if (progress && that.repository.status == RepositoryStatus.DOWNLOAD) {
|
||||
await that.repository.updateStatus(
|
||||
that.repository.status,
|
||||
progress.transferred.toString()
|
||||
);
|
||||
}
|
||||
progressTimeout = setTimeout(updateProgress, 1500);
|
||||
}
|
||||
}
|
||||
@@ -123,7 +124,11 @@ export default class GitHubDownload extends GitHubBase implements SourceBase {
|
||||
}
|
||||
|
||||
this.repository.model.isReseted = false;
|
||||
await this.repository.updateStatus(RepositoryStatus.READY);
|
||||
try {
|
||||
await this.repository.updateStatus(RepositoryStatus.READY);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
}
|
||||
|
||||
async getFileContent(file: AnonymizedFile): Promise<Readable> {
|
||||
|
||||
Reference in New Issue
Block a user