mirror of
https://github.com/tdurieux/anonymous_github.git
synced 2026-07-01 19:45:33 +02:00
fix: fix github download
This commit is contained in:
@@ -39,7 +39,12 @@ export default class GitHubDownload extends GitHubBase implements SourceBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async download() {
|
async download() {
|
||||||
if (this.repository.status == "download")
|
const fiveMinuteAgo = new Date();
|
||||||
|
fiveMinuteAgo.setMinutes(fiveMinuteAgo.getMinutes() - 5);
|
||||||
|
if (
|
||||||
|
this.repository.status == "download" &&
|
||||||
|
this.repository.model.statusDate > fiveMinuteAgo
|
||||||
|
)
|
||||||
throw new AnonymousError("repo_in_download", this.repository);
|
throw new AnonymousError("repo_in_download", this.repository);
|
||||||
let response: OctokitResponse<unknown, number>;
|
let response: OctokitResponse<unknown, number>;
|
||||||
try {
|
try {
|
||||||
@@ -78,28 +83,18 @@ export default class GitHubDownload extends GitHubBase implements SourceBase {
|
|||||||
}
|
}
|
||||||
updateProgress();
|
updateProgress();
|
||||||
|
|
||||||
await storage.extractTar(
|
try {
|
||||||
originalPath,
|
const downloadStream = got.stream(response.url);
|
||||||
got
|
downloadStream.addListener("downloadProgress", (p) => (progress = p));
|
||||||
.stream(response.url)
|
await storage.extractTar(originalPath, downloadStream);
|
||||||
.on("downloadProgress", async (p) => {
|
} catch (error) {
|
||||||
inDownload = true;
|
await this.repository.updateStatus("error", "unable_to_download");
|
||||||
progress = p;
|
throw new AnonymousError("unable_to_download");
|
||||||
})
|
} finally {
|
||||||
.on("error", (error) => {
|
inDownload = false;
|
||||||
inDownload = false;
|
clearTimeout(progressTimeout);
|
||||||
clearTimeout(progressTimeout);
|
}
|
||||||
})
|
|
||||||
.on("end", () => {
|
|
||||||
inDownload = false;
|
|
||||||
console.log("download finished");
|
|
||||||
clearTimeout(progressTimeout);
|
|
||||||
})
|
|
||||||
.on("close", () => clearTimeout(progressTimeout))
|
|
||||||
);
|
|
||||||
|
|
||||||
inDownload = false;
|
|
||||||
clearTimeout(progressTimeout);
|
|
||||||
await this.repository.updateStatus("ready");
|
await this.repository.updateStatus("ready");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user