Skip to content
This repository has been archived by the owner on Nov 29, 2023. It is now read-only.

Commit

Permalink
fix multiple download bug
Browse files Browse the repository at this point in the history
When the archive is particularly large, files would be downloaded
multiple times.
  • Loading branch information
tom-james-watson committed Dec 8, 2018
1 parent 9ceecae commit 2278a5a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dat-cp",
"version": "0.7.0",
"version": "0.7.1",
"description": "Dat Copy - remote file copy, powered by the dat protocol",
"engines": {
"node": ">=6.0.0"
Expand Down
9 changes: 6 additions & 3 deletions src/lib/dat-cp.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,11 +192,10 @@ export default class DatCp {
process.exit(1)
}, 15000)

const readRoot = setInterval(async () => {
const readRoot = async () => {
const paths = await this.readdir('/')

if (paths.length !== 0) {
clearInterval(readRoot)
clearTimeout(abort)

for (const path of paths) {
Expand All @@ -211,8 +210,12 @@ export default class DatCp {
this.printTotal()
}
resolve()
} else {
setTimeout(readRoot, 300)
}
}, 300)
}

readRoot()
})
}

Expand Down

0 comments on commit 2278a5a

Please sign in to comment.