For bug #158608, don't attempt to use distlocks when it's detected that the filesyste...
authorZac Medico <zmedico@gentoo.org>
Wed, 20 Dec 2006 02:17:02 +0000 (02:17 -0000)
committerZac Medico <zmedico@gentoo.org>
Wed, 20 Dec 2006 02:17:02 +0000 (02:17 -0000)
svn path=/main/trunk/; revision=5330

pym/portage.py

index d0f2bbe5f4c8fdfc40efb1ab98d692182b6b5a39..c418325571df650b0add9d712f0cf8b40103e1d7 100644 (file)
@@ -2169,11 +2169,21 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0, locks_in_subdir=".locks",
 
        can_fetch=True
 
+       if listonly:
+               can_fetch = False
+
        for var_name in ("FETCHCOMMAND", "RESUMECOMMAND"):
                if not mysettings.get(var_name, None):
                        can_fetch = False
 
-       if not listonly:
+       if can_fetch and \
+               not fetch_to_ro and \
+               not os.access(mysettings["DISTDIR"], os.W_OK):
+               writemsg("!!! No write access to '%s'\n" % mysettings["DISTDIR"],
+                       noiselevel=-1)
+               can_fetch = False
+
+       if can_fetch:
                dirmode  = 02070
                filemode =   060
                modemask =    02
@@ -2200,12 +2210,7 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0, locks_in_subdir=".locks",
                                writemsg("!!! Directory Not Found: DISTDIR='%s'\n" % mysettings["DISTDIR"], noiselevel=-1)
                                writemsg("!!! Fetching will fail!\n", noiselevel=-1)
 
-       if not os.access(mysettings["DISTDIR"]+"/",os.W_OK):
-               if not fetch_to_ro:
-                       print "!!! No write access to %s" % mysettings["DISTDIR"]+"/"
-                       can_fetch=False
-       else:
-               if use_locks and locks_in_subdir:
+       if can_fetch and use_locks and locks_in_subdir:
                        distlocks_subdir = os.path.join(mysettings["DISTDIR"], locks_in_subdir)
                        if not os.access(distlocks_subdir, os.W_OK):
                                writemsg("!!! No write access to write to %s.  Aborting.\n" % distlocks_subdir,
@@ -2328,16 +2333,7 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0, locks_in_subdir=".locks",
                                        else:
                                                continue
 
-                               # check if we can actually write to the directory/existing file.
-                               if fetched!=2 and os.path.exists(mysettings["DISTDIR"]+"/"+myfile) != \
-                                       os.access(mysettings["DISTDIR"]+"/"+myfile, os.W_OK) and not fetch_to_ro:
-                                       writemsg( red("***") + \
-                                               " Lack write access to %s, failing fetch\n" % \
-                                               os.path.join(mysettings["DISTDIR"], myfile),
-                                               noiselevel=-1)
-                                       fetched=0
-                                       break
-                               elif fetched!=2:
+                               if fetched != 2:
                                        #we either need to resume or start the download
                                        #you can't use "continue" when you're inside a "try" block
                                        if fetched==1: