add repository status page

This commit is contained in:
tdurieux
2021-04-06 10:01:53 +02:00
parent fcdaf69b6a
commit 22465d455c
7 changed files with 193 additions and 14 deletions

View File

@@ -51,6 +51,7 @@ module.exports.downloadRepoAndAnonymize = async (repoConfig) => {
return true;
} else if (repoConfig.options.mode == "stream") {
// in stream mode only download the list of file from github
await repoUtils.updateStatus(repoConfig, "downloading");
await fileUtils.getFileList({ repoConfig });
await repoUtils.updateStatus(repoConfig, "ready");
return true;

View File

@@ -139,11 +139,19 @@ module.exports.downloadRepoZip = async (repoConfig, target) => {
});
};
module.exports.updateStatus = async (repoConfig, status) => {
module.exports.updateStatus = async (repoConfig, status, errorMessage) => {
repoConfig.status = status;
repoConfig.errorMessage = errorMessage;
const update = { $set: { status } };
if (!errorMessage) {
update["$unset"] = { errorMessage: "" };
} else {
update["$set"].errorMessage = errorMessage;
}
await db
.get("anonymized_repositories")
.updateOne({ repoId: repoConfig.repoId }, { $set: { status } });
.updateOne({ repoId: repoConfig.repoId }, update);
};
module.exports.downloadOriginalRepo = async (repoConfig, destination) => {