Always return early from NewsManager.updateItems() if self.unread_path can't
authorZac Medico <zmedico@gentoo.org>
Thu, 13 Nov 2008 01:50:06 +0000 (01:50 -0000)
committerZac Medico <zmedico@gentoo.org>
Thu, 13 Nov 2008 01:50:06 +0000 (01:50 -0000)
be created.

svn path=/main/trunk/; revision=11868

pym/portage/news.py

index 6c0712d3a0a66744a1b63a2bd5d9f66bbfbac72a..332e05dc1cd4239936b0bdea2cf2c8f737c43373 100644 (file)
@@ -16,7 +16,7 @@ from portage.util import apply_permissions, ensure_dirs, grabfile, \
 from portage.data import portage_gid
 from portage.dep import isvalidatom
 from portage.locks import lockfile, unlockfile
-from portage.exception import OperationNotPermitted
+from portage.exception import OperationNotPermitted, PermissionDenied
 
 class NewsManager(object):
        """
@@ -50,15 +50,6 @@ class NewsManager(object):
                                profile_path = profile_path[len(profiles_base):]
                self._profile_path = profile_path
 
-               # Ensure that the unread path exists and is writable.
-               dirmode  = 02070
-               modemask =    02
-               try:
-                       ensure_dirs(self.unread_path, mode=dirmode,
-                               mask=modemask, gid=portage_gid)
-               except OperationNotPermitted:
-                       pass
-
        def updateItems(self, repoid):
                """
                Figure out which news items from NEWS_PATH are both unread and relevant to
@@ -66,6 +57,17 @@ class NewsManager(object):
                items into the news.repoid.unread file.
                """
 
+               # Ensure that the unread path exists and is writable.
+               dirmode  = 00700
+               modemask =   022
+               try:
+                       ensure_dirs(self.unread_path, mode=dirmode, mask=modemask)
+               except (OperationNotPermitted, PermissionDenied):
+                       return
+
+               if not os.access(self.unread_path, os.W_OK):
+                       return
+
                repos = self.portdb.getRepositories()
                if repoid not in repos:
                        raise ValueError("Invalid repoID: %s" % repoid)