Skip to content

Commit 65e3c35

Browse files
committed
Merge pull request #1548 from grahame/fix-interrupted-downloads
don't leave files that will not checksum if download is interrupted
2 parents f14ee0b + ca8fe64 commit 65e3c35

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/etc/snapshot.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,13 @@ def local_rev_committer_date():
117117
return local_rev_info("ci")
118118

119119
def get_url_to_file(u,f):
120-
subprocess.check_call(["curl", "-o", f, u])
120+
tmpf = f + '.tmp' # no security issue, just to stop partial download leaving a stale file
121+
try:
122+
subprocess.check_call(["curl", "-o", tmpf, u])
123+
except subprocess.CalledProcessError:
124+
os.unlink(tmpf)
125+
raise
126+
os.rename(tmpf, f)
121127

122128
def snap_filename_hash_part(snap):
123129
match = re.match(r".*([a-fA-F\d]{40}).tar.bz2$", snap)

0 commit comments

Comments
 (0)