diff --git a/pyvo/utils/download.py b/pyvo/utils/download.py index 56452dc9f..ccdf08d0f 100644 --- a/pyvo/utils/download.py +++ b/pyvo/utils/download.py @@ -69,8 +69,7 @@ def http_download(url, length = None if cache and os.path.exists(local_filepath): - with open(local_filepath, 'rb') as fp: - local_size = os.path.getsize(local_filepath) + local_size = os.stat(local_filepath).st_size if length is not None and local_size != length: warn('Found cached file but it has the wrong size. Overwriting ...', category=PyvoUserWarning) @@ -235,8 +234,7 @@ def aws_download(uri=None, if cache and os.path.exists(local_filepath): if length is not None: - with open(local_filepath, 'rb') as fp: - local_size = os.path.getsize(local_filepath) + local_size = os.stat(local_filepath).st_size if local_size == length: # found cached file with expected size. Stop if verbose: