Skip to content

Commit

Permalink
feat: 下载给个retry
Browse files Browse the repository at this point in the history
  • Loading branch information
bangbang93 committed Jan 25, 2024
1 parent 8db53c0 commit 4500f08
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/cluster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ export class Cluster {
const path = join(this.cacheDir, hashToFilename(file.hash))
return !await fse.pathExists(path)
})
if (missingFiles.length === 0) {
return
}
console.log(`mismatch ${missingFiles.length} files, start syncing`)
const totalSize = sum(missingFiles.map((file) => file.size))
const bar = new ProgressBar('downloading [:bar] :current/:total eta:etas :percent :rateBps', {
Expand All @@ -127,6 +130,9 @@ export class Cluster {
searchParams: {
noopen: process.env.FORCE_NOOPEN === 'true' ? 1 : '',
},
retry: {
limit: 10,
},
})
.on('downloadProgress', (progress) => {
bar.tick(progress.transferred - lastProgress)
Expand Down

0 comments on commit 4500f08

Please sign in to comment.