diff options
author | Zac Medico <zmedico@gentoo.org> | 2007-07-21 00:24:06 +0000 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2007-07-21 00:24:06 +0000 |
commit | 61921aa02bc6bd78555c77d5a22dc8714df6e39a (patch) | |
tree | d5ae720a02c2d82ff23633c8f4dfff57cc659783 | |
parent | cfc11a56a74ae60cc5ef0f81958ded0bc8a48f25 (diff) | |
download | portage-61921aa02bc6bd78555c77d5a22dc8714df6e39a.tar.gz portage-61921aa02bc6bd78555c77d5a22dc8714df6e39a.tar.bz2 portage-61921aa02bc6bd78555c77d5a22dc8714df6e39a.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. (trunk r7325)
svn path=/main/branches/2.1.2/; revision=7326
-rw-r--r-- | pym/portage.py | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/pym/portage.py b/pym/portage.py index cde08aa7e..b7d938237 100644 --- a/pym/portage.py +++ b/pym/portage.py @@ -2654,9 +2654,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 = output.EOutput() eout.quiet = \ @@ -2819,8 +2825,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 = output.EOutput() |