mirror of
https://github.com/tdurieux/anonymous_github.git
synced 2026-05-30 12:39:28 +02:00
feat: check repository size when repo is updated
This commit is contained in:
+23
-1
@@ -18,6 +18,8 @@ import { downloadQueue, removeQueue } from "./queue";
|
|||||||
import { isConnected } from "./database/database";
|
import { isConnected } from "./database/database";
|
||||||
import AnonymizedFile from "./AnonymizedFile";
|
import AnonymizedFile from "./AnonymizedFile";
|
||||||
import AnonymizedRepositoryModel from "./database/anonymizedRepositories/anonymizedRepositories.model";
|
import AnonymizedRepositoryModel from "./database/anonymizedRepositories/anonymizedRepositories.model";
|
||||||
|
import { getRepositoryFromGitHub } from "./source/GitHubRepository";
|
||||||
|
import config from "../config";
|
||||||
|
|
||||||
function anonymizeTreeRecursive(
|
function anonymizeTreeRecursive(
|
||||||
tree: TreeElement,
|
tree: TreeElement,
|
||||||
@@ -213,7 +215,27 @@ export default class Repository {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
this._model.anonymizeDate = new Date();
|
this._model.anonymizeDate = new Date();
|
||||||
console.log(`${this._model.repoId} will be updated to ${newCommit}`);
|
console.log(
|
||||||
|
`[UPDATE] ${this._model.repoId} will be updated to ${newCommit}`
|
||||||
|
);
|
||||||
|
|
||||||
|
if (this.source.type == "GitHubDownload") {
|
||||||
|
const repository = await getRepositoryFromGitHub({
|
||||||
|
accessToken: await this.source.getToken(),
|
||||||
|
owner: this.source.githubRepository.owner,
|
||||||
|
repo: this.source.githubRepository.repo,
|
||||||
|
});
|
||||||
|
if (
|
||||||
|
repository.size === undefined ||
|
||||||
|
repository.size > config.MAX_REPO_SIZE
|
||||||
|
) {
|
||||||
|
console.log(
|
||||||
|
`[UPDATE] ${this._model.repoId} will be streamed instead of downloaded`
|
||||||
|
);
|
||||||
|
this._model.source.type = "GitHubStream";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
await this.resetSate(RepositoryStatus.PREPARING);
|
await this.resetSate(RepositoryStatus.PREPARING);
|
||||||
await downloadQueue.add(this.repoId, this, {
|
await downloadQueue.add(this.repoId, this, {
|
||||||
jobId: this.repoId,
|
jobId: this.repoId,
|
||||||
|
|||||||
Reference in New Issue
Block a user