summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarius Mauch <genone@gentoo.org>2008-03-03 19:43:18 +0000
committerMarius Mauch <genone@gentoo.org>2008-03-03 19:43:18 +0000
commit9c7530830a39e04c3cab3763163d2bb946b672a5 (patch)
tree254074f41b499e1809849b5d85137ffa1b5e42ad
parenta310f282fb18b6385f386830bf4aa36fe16b41cf (diff)
downloadportage-9c7530830a39e04c3cab3763163d2bb946b672a5.tar.gz
portage-9c7530830a39e04c3cab3763163d2bb946b672a5.tar.bz2
portage-9c7530830a39e04c3cab3763163d2bb946b672a5.zip
check available space in DISTDIR before trying to fetch/copy a file, bug #212152
svn path=/main/trunk/; revision=9425
-rw-r--r--pym/portage/__init__.py13
1 files changed, 11 insertions, 2 deletions
diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py
index d5daf9648..ef848bf0d 100644
--- a/pym/portage/__init__.py
+++ b/pym/portage/__init__.py
@@ -3208,10 +3208,19 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0, locks_in_subdir=".locks",
"""
myfile_path = os.path.join(mysettings["DISTDIR"], myfile)
fetched=0
+ has_space = True
file_lock = None
if listonly:
writemsg_stdout("\n", noiselevel=-1)
else:
+ # check if there is enough space in DISTDIR to completely store myfile
+ # overestimate the filesize so we aren't bitten by FS overhead
+ vfs_stat = os.statvfs(mysettings["DISTDIR"])
+ if myfile in mydigests \
+ and (mydigests[myfile]["size"] + 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
+
if use_locks and can_fetch:
waiting_msg = None
if "parallel-fetch" in features:
@@ -3228,7 +3237,7 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0, locks_in_subdir=".locks",
waiting_msg=waiting_msg)
try:
if not listonly:
- if fsmirrors and not os.path.exists(myfile_path):
+ if fsmirrors and not os.path.exists(myfile_path) and has_space:
for mydir in fsmirrors:
mirror_file = os.path.join(mydir, myfile)
try:
@@ -3349,7 +3358,7 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0, locks_in_subdir=".locks",
else:
continue
- if fetched != 2:
+ if fetched != 2 and has_space:
#we either need to resume or start the download
#you can't use "continue" when you're inside a "try" block
if fetched==1: