Skip to content

Commit

Permalink
limit retries
Browse files Browse the repository at this point in the history
  • Loading branch information
elasticroentgen committed Mar 22, 2024
1 parent c2c88cd commit 789d863
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ async function ensureOrg(gitea, org, func) {
})
}

async function mirrorOnGitea(repository, gitea, giteaUser, githubToken, giteaOwner) {
async function mirrorOnGitea(repository, gitea, giteaUser, githubToken, giteaOwner, retry) {
const mirror_ok = await request.post(`${gitea.url}/api/v1/repos/migrate`)
.set('Authorization', 'token ' + gitea.token)
.send({
Expand All @@ -116,7 +116,7 @@ async function mirrorOnGitea(repository, gitea, giteaUser, githubToken, giteaOwn
return false;
});

if(!mirror_ok) {
if(!mirror_ok && !retry) {
console.log(`\tRetrying ${repository.name} in 10sec`);
await delay(10000);

Expand All @@ -127,7 +127,7 @@ async function mirrorOnGitea(repository, gitea, giteaUser, githubToken, giteaOwn
.then(async () => {
await delay(5000);
console.log("\tRetrying...")
await mirrorOnGitea(repository, gitea, giteaUser, githubToken, giteaOwner)
await mirrorOnGitea(repository, gitea, giteaUser, githubToken, giteaOwner, true)
})

}
Expand All @@ -142,7 +142,7 @@ async function mirror(repository, gitea, giteaUser, githubToken, giteaOwner) {
return;
}
console.log('\tMirroring repository to gitea: ', repository.name);
await mirrorOnGitea(repository, gitea, giteaUser, githubToken, giteaOwner);
await mirrorOnGitea(repository, gitea, giteaUser, githubToken, giteaOwner, false);
await delay(2500)
}

Expand Down

0 comments on commit 789d863

Please sign in to comment.