1 |
Author: zmedico |
2 |
Date: 2008-03-28 11:38:34 +0000 (Fri, 28 Mar 2008) |
3 |
New Revision: 9544 |
4 |
|
5 |
Modified: |
6 |
main/branches/2.1.2/pym/portage.py |
7 |
Log: |
8 |
Bug #212152 - Check available space in DISTDIR before trying to |
9 |
fetch/copy a file. (trunk r9425, r9502, and 9504:9506) |
10 |
|
11 |
|
12 |
Modified: main/branches/2.1.2/pym/portage.py |
13 |
=================================================================== |
14 |
--- main/branches/2.1.2/pym/portage.py 2008-03-28 11:32:06 UTC (rev 9543) |
15 |
+++ main/branches/2.1.2/pym/portage.py 2008-03-28 11:38:34 UTC (rev 9544) |
16 |
@@ -3184,10 +3184,28 @@ |
17 |
""" |
18 |
myfile_path = os.path.join(mysettings["DISTDIR"], myfile) |
19 |
fetched=0 |
20 |
+ has_space = True |
21 |
file_lock = None |
22 |
if listonly: |
23 |
writemsg_stdout("\n", noiselevel=-1) |
24 |
else: |
25 |
+ # check if there is enough space in DISTDIR to completely store myfile |
26 |
+ # overestimate the filesize so we aren't bitten by FS overhead |
27 |
+ if hasattr(os, "statvfs"): |
28 |
+ vfs_stat = os.statvfs(mysettings["DISTDIR"]) |
29 |
+ try: |
30 |
+ mysize = os.stat(myfile_path).st_size |
31 |
+ except OSError, e: |
32 |
+ if e.errno != errno.ENOENT: |
33 |
+ raise |
34 |
+ del e |
35 |
+ mysize = 0 |
36 |
+ if myfile in mydigests \ |
37 |
+ and (mydigests[myfile]["size"] - mysize + vfs_stat.f_bsize) >= \ |
38 |
+ (vfs_stat.f_bsize * vfs_stat.f_bavail): |
39 |
+ writemsg("!!! Insufficient space to store %s in %s\n" % (myfile, mysettings["DISTDIR"]), noiselevel=-1) |
40 |
+ has_space = False |
41 |
+ |
42 |
if use_locks and can_fetch: |
43 |
waiting_msg = None |
44 |
if "parallel-fetch" in features: |
45 |
@@ -3204,7 +3222,7 @@ |
46 |
waiting_msg=waiting_msg) |
47 |
try: |
48 |
if not listonly: |
49 |
- if fsmirrors and not os.path.exists(myfile_path): |
50 |
+ if fsmirrors and not os.path.exists(myfile_path) and has_space: |
51 |
for mydir in fsmirrors: |
52 |
mirror_file = os.path.join(mydir, myfile) |
53 |
try: |
54 |
@@ -3325,7 +3343,7 @@ |
55 |
else: |
56 |
continue |
57 |
|
58 |
- if fetched != 2: |
59 |
+ if fetched != 2 and has_space: |
60 |
#we either need to resume or start the download |
61 |
#you can't use "continue" when you're inside a "try" block |
62 |
if fetched==1: |
63 |
|
64 |
-- |
65 |
gentoo-commits@l.g.o mailing list |