summaryrefslogtreecommitdiffstats
path: root/pym
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2007-07-30 06:54:20 +0000
committerZac Medico <zmedico@gentoo.org>2007-07-30 06:54:20 +0000
commit5a81f4a5e22848b7c9c19c8cc4ae3bfec3df42e1 (patch)
tree99867da7a44bf60e1801a01573d4538fa9528844 /pym
parentfa46d408abfad360f6de4fa777ca74818ac0cfcf (diff)
downloadportage-5a81f4a5e22848b7c9c19c8cc4ae3bfec3df42e1.tar.gz
portage-5a81f4a5e22848b7c9c19c8cc4ae3bfec3df42e1.tar.bz2
portage-5a81f4a5e22848b7c9c19c8cc4ae3bfec3df42e1.zip
For bug #162923, 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. (branches/2.1.2 r7326)
svn path=/main/branches/2.1.2.9/; revision=7502
Diffstat (limited to 'pym')
-rw-r--r--pym/portage.py23
1 files changed, 18 insertions, 5 deletions
diff --git a/pym/portage.py b/pym/portage.py
index 3f21c7532..8f1a16957 100644
--- a/pym/portage.py
+++ b/pym/portage.py
@@ -2570,9 +2570,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 = \
@@ -2735,8 +2741,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()