From e94a5f164ad3f015176454efbf206f7d7f060749 Mon Sep 17 00:00:00 2001 From: tdurieux Date: Wed, 5 Apr 2023 12:12:16 +0200 Subject: [PATCH] disable download mode for the moment --- public/partials/anonymize.htm | 64 ++------------------------------ public/script/app.js | 40 +++----------------- src/Repository.ts | 4 +- src/routes/repository-private.ts | 37 +++++++++--------- src/source/GitHubDownload.ts | 2 +- 5 files changed, 31 insertions(+), 116 deletions(-) diff --git a/public/partials/anonymize.htm b/public/partials/anonymize.htm index d1412a5..d55073c 100644 --- a/public/partials/anonymize.htm +++ b/public/partials/anonymize.htm @@ -13,14 +13,9 @@ name="anonymize" novalidate > -
Anonymize a repository
-
- Fill the information to anonymize! It will only take 5min. -
-

Source

+

Anonymize your repository

-
- +
@@ -58,37 +54,6 @@ {{repoUrl}} is already anonymized
- -
- -
- -
- -
-
-
@@ -386,29 +351,6 @@ >Display Notebooks
- -
- - - How the repository will be anonymized. Stream mode - will request the content on the flight. This is the - only option for repositories bigger than - {{site_options.MAX_REPO_SIZE * 1024| humanFileSize}}. - This repository is {{details.size * 8 *1024 | - humanFileSize}}. Download will download the repository - the repository on the anonymous.4open.science server, - it is faster and offer more features. -
diff --git a/public/script/app.js b/public/script/app.js index 9bb968a..86c00ca 100644 --- a/public/script/app.js +++ b/public/script/app.js @@ -999,9 +999,7 @@ angular $scope.terms = ""; $scope.defaultTerms = ""; $scope.branches = []; - $scope.repositories = []; $scope.source = { - type: "GitHubStream", branch: "", commit: "", }; @@ -1079,17 +1077,6 @@ angular } }); - $scope.getRepositories = (force) => { - $http - .get("/api/user/all_repositories", { - params: { force: force === true ? "1" : "0" }, - }) - .then((res) => { - $scope.repositories = res.data; - }); - }; - $scope.getRepositories(); - $scope.repoSelected = async () => { $scope.terms = $scope.defaultTerms; $scope.repoId = ""; @@ -1176,14 +1163,6 @@ angular resetValidity(); const res = await $http.get(`/api/repo/${o.owner}/${o.repo}/`); $scope.details = res.data; - if ($scope.details.size > $scope.site_options.MAX_REPO_SIZE) { - $scope.anonymize.mode.$$element[0].disabled = true; - - $scope.$apply(() => { - $scope.source.type = "GitHubStream"; - checkSourceType(); - }); - } if (!$scope.repoId) { $scope.repoId = $scope.details.repo + "-" + generateRandomId(4); } @@ -1453,7 +1432,7 @@ angular const selected = $scope.branches.filter( (f) => f.name == $scope.source.branch )[0]; - checkSourceType(); + checkHasPage(); if (selected) { $scope.source.commit = selected.commit; @@ -1464,22 +1443,15 @@ angular } }); - function checkSourceType() { - if ($scope.source.type == "GitHubStream") { - $scope.options.page = false; - //$scope.anonymize.page.$$element[0].disabled = true; - } else { - if ($scope.details && $scope.details.hasPage) { - $scope.anonymize.page.$$element[0].disabled = false; - if ($scope.details.pageSource.branch != $scope.source.branch) { - $scope.anonymize.page.$$element[0].disabled = true; - } + function checkHasPage() { + if ($scope.details && $scope.details.hasPage) { + $scope.anonymize.page.$$element[0].disabled = false; + if ($scope.details.pageSource.branch != $scope.source.branch) { + $scope.anonymize.page.$$element[0].disabled = true; } } } - $scope.$watch("source.type", checkSourceType); - $scope.$watch("terms", anonymize); $scope.$watch("options.image", anonymize); $scope.$watch("options.link", anonymize); diff --git a/src/Repository.ts b/src/Repository.ts index b5cf972..659adc4 100644 --- a/src/Repository.ts +++ b/src/Repository.ts @@ -56,8 +56,8 @@ export default class Repository { this._model = data; switch (data.source.type) { case "GitHubDownload": - this.source = new GitHubDownload(data.source, this); - break; + // this.source = new GitHubDownload(data.source, this); + // break; case "GitHubStream": this.source = new GitHubStream(data.source, this); break; diff --git a/src/routes/repository-private.ts b/src/routes/repository-private.ts index 68166ce..0e0de6d 100644 --- a/src/routes/repository-private.ts +++ b/src/routes/repository-private.ts @@ -468,28 +468,29 @@ router.post("/", async (req: express.Request, res: express.Response) => { repo.owner = user.id; updateRepoModel(repo, repoUpdate); + repo.source.type = "GitHubStream"; repo.source.accessToken = user.accessToken; repo.source.repositoryId = repository.model.id; repo.source.repositoryName = repoUpdate.fullName; - if (repo.source.type == "GitHubDownload") { - // details.size is in kilobytes - if ( - repository.size === undefined || - repository.size > config.MAX_REPO_SIZE - ) { - throw new AnonymousError("invalid_mode", { - object: repository, - httpStatus: 400, - }); - } - } - if ( - repository.size !== undefined && - repository.size < config.AUTO_DOWNLOAD_REPO_SIZE - ) { - repo.source.type = "GitHubDownload"; - } + // if (repo.source.type === "GitHubDownload") { + // // details.size is in kilobytes + // if ( + // repository.size === undefined || + // repository.size > config.MAX_REPO_SIZE + // ) { + // throw new AnonymousError("invalid_mode", { + // object: repository, + // httpStatus: 400, + // }); + // } + // } + // if ( + // repository.size !== undefined && + // repository.size < config.AUTO_DOWNLOAD_REPO_SIZE + // ) { + // repo.source.type = "GitHubDownload"; + // } repo.conference = repoUpdate.conference; await repo.save(); diff --git a/src/source/GitHubDownload.ts b/src/source/GitHubDownload.ts index 6c33620..5f634d9 100644 --- a/src/source/GitHubDownload.ts +++ b/src/source/GitHubDownload.ts @@ -91,7 +91,7 @@ export default class GitHubDownload extends GitHubBase implements SourceBase { const that = this; async function updateProgress() { - if (progress && that.repository.status) { + if (progress && that.repository.status == RepositoryStatus.DOWNLOAD) { await that.repository.updateStatus( that.repository.status, progress.transferred.toString()