Skip to content

Commit

Permalink
Customize download log messages in cached_download function
Browse files Browse the repository at this point in the history
  • Loading branch information
wkentaro committed Feb 2, 2024
1 parent 314a84b commit 4c5cd58
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions gdown/cached_download.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,15 +129,17 @@ def cached_download(
try:
temp_path = osp.join(temp_root, "dl")

if not quiet:
msg = "Cached Downloading"
if path:
msg = f"{msg}: {path}"
else:
msg = f"{msg}..."
print(msg, file=sys.stderr)

download(url, temp_path, quiet=quiet, **kwargs)
log_message_hash = f"Hash: {hash}\n" if hash else ""
download(
url=url,
output=temp_path,
quiet=quiet,
log_messages={
"start": f"Cached downloading...\n{log_message_hash}",
"output": f"To: {path}\n",
},
**kwargs,
)
with filelock.FileLock(lock_path):
shutil.move(temp_path, path)
except Exception:
Expand Down

0 comments on commit 4c5cd58

Please sign in to comment.