Skip to content

Commit

Permalink
fix: download duplicate file size, check with threshold
Browse files Browse the repository at this point in the history
  • Loading branch information
HYDlink committed Jan 21, 2022
1 parent 935f8ca commit 9a878b5
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion utils/downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ def _download_file(url, dir, headers):
# obtain content length
length = int(r.headers['content-length'])
echo.clog(f'file size: {size_description(length)}')
if os.path.exists(dir) and os.path.getsize(dir) == length:
THRESHOLD = 8
if os.path.exists(dir) and abs(os.path.getsize(dir) - length) < THRESHOLD:
echo.clog(f'file already exists {dir}')
else:
# start writing
Expand Down

0 comments on commit 9a878b5

Please sign in to comment.