summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2009-03-02 21:50:22 +0000
committerZac Medico <zmedico@gentoo.org>2009-03-02 21:50:22 +0000
commit9c1a530af1edfd787ff8ade710f688d7a9d89167 (patch)
tree01101e9c5572c4dcb0669b80b5af1e750f392d8c
parent35db7995ca8762d7faa3e2b9b6201f6b0c00fcb2 (diff)
downloadportage-9c1a530af1edfd787ff8ade710f688d7a9d89167.tar.gz
portage-9c1a530af1edfd787ff8ade710f688d7a9d89167.tar.bz2
portage-9c1a530af1edfd787ff8ade710f688d7a9d89167.zip
When fetch() is called and there is an existing file with the wrong size that
is smaller than PORTAGE_FETCH_RESUME_MIN_SIZE, rename the file instead of deleting it. This is more friendly for cases in which the user is attempting to regenerate the digest but has not used `ebuild --force foo.ebuild manifest` like they're supposed to. Thanks to Patrick Lauer <patrick@g.o> for reporting. svn path=/main/trunk/; revision=12739
-rw-r--r--pym/portage/__init__.py22
1 files changed, 15 insertions, 7 deletions
diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py
index 7fc3160d9..68f2dbbbd 100644
--- a/pym/portage/__init__.py
+++ b/pym/portage/__init__.py
@@ -3901,15 +3901,23 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0, locks_in_subdir=".locks",
elif distdir_writable:
if mystat.st_size < fetch_resume_size and \
mystat.st_size < size:
- writemsg((">>> Deleting distfile with size " + \
+ # If the file already exists and the size does not
+ # match the existing digests, it may be that the
+ # user is attempting to update the digest. In this
+ # case, the digestgen() function will advise the
+ # user to use `ebuild --force foo.ebuild manifest`
+ # in order to force the old digests to be replaced.
+ # Since the user may want to keep this file, rename
+ # it instead of deleting it.
+ writemsg((">>> Renaming distfile with size " + \
"%d (smaller than " "PORTAGE_FETCH_RESU" + \
"ME_MIN_SIZE)\n") % mystat.st_size)
- try:
- os.unlink(myfile_path)
- except OSError, e:
- if e.errno != errno.ENOENT:
- raise
- del e
+ temp_filename = \
+ _checksum_failure_temp_file(
+ mysettings["DISTDIR"], myfile)
+ writemsg_stdout("Refetching... " + \
+ "File renamed to '%s'\n\n" % \
+ temp_filename, noiselevel=-1)
elif mystat.st_size >= size:
temp_filename = \
_checksum_failure_temp_file(