"""
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:
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:
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: