Skip to content

Commit a4fed63

Browse files
authored
bump to v0.2.1
trying to make downloads safer using explicit flush, explicit close, and open with buffer. will likely need to do something more involved to ensure content-lengths are correct.
2 parents 524e01a + 40e3e43 commit a4fed63

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

moody/moody.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -313,11 +313,14 @@ def download_edr_img_files(product, https, chunk_size):
313313

314314

315315
def download_file(url, filename, chunk_size):
316-
with closing(requests.get(url, stream=True)) as r:
317-
with open(filename, "wb") as output:
316+
with open(filename, "wb", chunk_size) as output:
317+
with closing(requests.get(url, stream=True)) as r:
318318
for chunk in tqdm(r.iter_content(chunk_size), desc=f'Downloading {filename}'):
319319
if chunk:
320320
output.write(chunk)
321+
output.flush()
322+
r.close()
323+
output.flush()
321324
if str(filename).endswith('.zip'):
322325
shutil.unpack_archive(filename)
323326
if os.path.exists(filename):

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
# some influences here came from https://github.com/audreyr/cookiecutter/blob/master/setup.py
55

6-
version = '0.2.0'
6+
version = '0.2.1'
77

88
with io.open('README.rst', 'r', encoding='utf-8') as readme_file:
99
readme = readme_file.read()

0 commit comments

Comments
 (0)