Bug #212152 - Account pre-existing files when calculating whether there
authorZac Medico <zmedico@gentoo.org>
Tue, 25 Mar 2008 03:51:51 +0000 (03:51 -0000)
committerZac Medico <zmedico@gentoo.org>
Tue, 25 Mar 2008 03:51:51 +0000 (03:51 -0000)
is enough space for a download.

svn path=/main/trunk/; revision=9505

pym/portage/__init__.py

index 66ff4ce290ebaa4bcb5f4347ff51e364282f2adf..6a253764f79e467a2e22665a8f368d068c4ca59c 100644 (file)
@@ -3243,8 +3243,16 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0, locks_in_subdir=".locks",
                        # overestimate the filesize so we aren't bitten by FS overhead
                        if hasattr(os, "statvfs"):
                                vfs_stat = os.statvfs(mysettings["DISTDIR"])
+                               try:
+                                       mysize = os.stat(myfile_path)
+                               except OSError, e:
+                                       if e.errno != errno.ENOENT:
+                                               raise
+                                       del e
+                                       mysize = 0
                                if myfile in mydigests \
-                                       and (mydigests[myfile]["size"] + vfs_stat.f_bsize) >= (vfs_stat.f_bsize * vfs_stat.f_bavail):
+                                       and (mydigests[myfile]["size"] - mysize + vfs_stat.f_bsize) >= \
+                                       (vfs_stat.f_bsize * vfs_stat.f_bavail):
                                        writemsg("!!! Insufficient space to store %s in %s\n" % (myfile, mysettings["DISTDIR"]), noiselevel=-1)
                                        has_space = False