summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2007-07-21 00:21:24 +0000
committerZac Medico <zmedico@gentoo.org>2007-07-21 00:21:24 +0000
commit9b41176873f43c1213bfe20a789989251b3d70aa (patch)
tree13c6a72228378fea69d24435fe7941c57d3a9b65
parent203ec4fdc3ef654ba93eb5a6db912a031cbd3314 (diff)
downloadportage-9b41176873f43c1213bfe20a789989251b3d70aa.tar.gz
portage-9b41176873f43c1213bfe20a789989251b3d70aa.tar.bz2
portage-9b41176873f43c1213bfe20a789989251b3d70aa.zip
When digest verification of a distfile fails, rename instead of unlinking it in case it's a large download and the user wants to salvage it due to a bad digest.
svn path=/main/trunk/; revision=7325
-rw-r--r--pym/portage/__init__.py23
1 files changed, 18 insertions, 5 deletions
diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py
index 7764dcbe1..4494caeb2 100644
--- a/pym/portage/__init__.py
+++ b/pym/portage/__init__.py
@@ -2765,9 +2765,15 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0, locks_in_subdir=".locks",
if reason[0] == "Insufficient data for checksum verification":
return 0
if can_fetch and not restrict_fetch:
- writemsg("Refetching...\n\n",
- noiselevel=-1)
- os.unlink(myfile_path)
+ from tempfile import mkstemp
+ fd, temp_filename = mkstemp("",
+ myfile + "._checksum_failure_.",
+ mysettings["DISTDIR"])
+ os.close(fd)
+ os.rename(myfile_path, temp_filename)
+ writemsg_stdout("Refetching... " + \
+ "File renamed to '%s'\n\n" % \
+ temp_filename, noiselevel=-1)
else:
eout = portage.output.EOutput()
eout.quiet = \
@@ -2930,8 +2936,15 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0, locks_in_subdir=".locks",
(reason[1], reason[2]), noiselevel=-1)
if reason[0] == "Insufficient data for checksum verification":
return 0
- writemsg("Removing corrupt distfile...\n", noiselevel=-1)
- os.unlink(mysettings["DISTDIR"]+"/"+myfile)
+ from tempfile import mkstemp
+ fd, temp_filename = mkstemp("",
+ myfile + "._checksum_failure_.",
+ mysettings["DISTDIR"])
+ os.close(fd)
+ os.rename(myfile_path, temp_filename)
+ writemsg_stdout("Refetching... " + \
+ "File renamed to '%s'\n\n" % \
+ temp_filename, noiselevel=-1)
fetched=0
else:
eout = portage.output.EOutput()