Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions lisa/base_tools/wget.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ def get(
sudo: bool = False,
force_run: bool = False,
timeout: int = 600,
skip_exists: bool = False,
) -> str:
cached_filename = self._url_file_cache.get(url, None)
if cached_filename:
Expand All @@ -66,8 +67,13 @@ def get(

# remove existing file and dir to download again.
download_pure_path = self.node.get_pure_path(download_path)
if overwrite and self.node.shell.exists(download_pure_path):
self.node.shell.remove(download_pure_path, recursive=True)
if self.node.shell.exists(download_pure_path):
if skip_exists or not overwrite:
self._url_file_cache[url] = download_path
return download_path
else:
self.node.shell.remove(download_pure_path, recursive=True)
Comment thread
mcgov marked this conversation as resolved.

command = f"'{url}' --no-check-certificate"
if filename:
command = f"{command} -O {download_path}"
Expand Down Expand Up @@ -171,6 +177,7 @@ def get(
sudo: bool = False,
force_run: bool = False,
timeout: int = 600,
skip_exists: bool = False,
) -> str:
cached_filename = self._url_file_cache.get(url, None)
if cached_filename:
Expand All @@ -187,11 +194,10 @@ def get(

file_path, download_path = self._ensure_download_path(file_path, filename)

# return if file exists and not overwrite
if ls.path_exists(file_path, sudo=sudo) and not overwrite:
self._log.debug(
f"File {download_path} already exists and rewrite is set to False"
)
# return early if file exists and caller doesn't want to overwrite
if ls.path_exists(download_path, sudo=sudo) and (skip_exists or not overwrite):
self._url_file_cache[url] = download_path
return download_path

# create directory if it doesn't exist
self.node.tools[Mkdir].create_directory(file_path, sudo=sudo)
Expand Down
Loading