Make NewsManager.updateItems() and getUnreadItems() return early if
authorZac Medico <zmedico@gentoo.org>
Sat, 15 Nov 2008 22:17:01 +0000 (22:17 -0000)
committerZac Medico <zmedico@gentoo.org>
Sat, 15 Nov 2008 22:17:01 +0000 (22:17 -0000)
PermissionDenied errors are encountered when attempting to read the
skip or unread files.

svn path=/main/branches/2.1.6/; revision=11957

pym/portage/news.py

index aa979dabd921657e175e8cbc1abd1ebcc61b3dbf..90dd3a065796eb1af512d6b17a873e3fab86b9c0 100644 (file)
@@ -100,10 +100,13 @@ class NewsManager(object):
                unread_filename = self._unread_filename(repoid)
                unread_lock = lockfile(unread_filename, wantnewlockfile=1)
                try:
-                       unread = set(grabfile(unread_filename))
-                       unread_orig = unread.copy()
-                       skip = set(grabfile(skip_filename))
-                       skip_orig = skip.copy()
+                       try:
+                               unread = set(grabfile(unread_filename))
+                               unread_orig = unread.copy()
+                               skip = set(grabfile(skip_filename))
+                               skip_orig = skip.copy()
+                       except PermissionDenied:
+                               return
 
                        updates = []
                        for itemid in news:
@@ -156,7 +159,10 @@ class NewsManager(object):
                except (InvalidLocation, OperationNotPermitted, PermissionDenied):
                        return 0
                try:
-                       return len(grabfile(unread_filename))
+                       try:
+                               return len(grabfile(unread_filename))
+                       except PermissionDenied:
+                               return 0
                finally:
                        if unread_lock:
                                unlockfile(unread_lock)