summaryrefslogtreecommitdiffstats
path: root/pym/portage.py
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2008-03-28 11:38:34 +0000
committerZac Medico <zmedico@gentoo.org>2008-03-28 11:38:34 +0000
commit75987f3f90a4e59a8608d5273c0ee79c6732ab16 (patch)
tree9edce24ae03da661acf39bee30247a7e5803ef35 /pym/portage.py
parent7a31040893394892b20c316cfac53f59a4a78c21 (diff)
downloadportage-75987f3f90a4e59a8608d5273c0ee79c6732ab16.tar.gz
portage-75987f3f90a4e59a8608d5273c0ee79c6732ab16.tar.bz2
portage-75987f3f90a4e59a8608d5273c0ee79c6732ab16.zip
Bug #212152 - Check available space in DISTDIR before trying to
fetch/copy a file. (trunk r9425, r9502, and 9504:9506) svn path=/main/branches/2.1.2/; revision=9544
Diffstat (limited to 'pym/portage.py')
-rw-r--r--pym/portage.py22
1 files changed, 20 insertions, 2 deletions
diff --git a/pym/portage.py b/pym/portage.py
index 681749402..684838035 100644
--- a/pym/portage.py
+++ b/pym/portage.py
@@ -3184,10 +3184,28 @@ 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
+ if hasattr(os, "statvfs"):
+ vfs_stat = os.statvfs(mysettings["DISTDIR"])
+ try:
+ mysize = os.stat(myfile_path).st_size
+ except OSError, e:
+ if e.errno != errno.ENOENT:
+ raise
+ del e
+ mysize = 0
+ if myfile in mydigests \
+ 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
+
if use_locks and can_fetch:
waiting_msg = None
if "parallel-fetch" in features:
@@ -3204,7 +3222,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:
@@ -3325,7 +3343,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: