summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlec Warner <antarus@gentoo.org>2007-01-18 07:15:10 +0000
committerAlec Warner <antarus@gentoo.org>2007-01-18 07:15:10 +0000
commitb029f2b8ba19501200f358c664d8ed5cbe42eec0 (patch)
tree3650f909603fdb501f2fb1346d38317473f96972
parent75252713bd394c7958a71535a655827d8b6168ae (diff)
downloadportage-b029f2b8ba19501200f358c664d8ed5cbe42eec0.tar.gz
portage-b029f2b8ba19501200f358c664d8ed5cbe42eec0.tar.bz2
portage-b029f2b8ba19501200f358c664d8ed5cbe42eec0.zip
locking, try 100
svn path=/main/trunk/; revision=5701
-rw-r--r--pym/portage_news.py32
1 files changed, 16 insertions, 16 deletions
diff --git a/pym/portage_news.py b/pym/portage_news.py
index bd2a40789..736dcf833 100644
--- a/pym/portage_news.py
+++ b/pym/portage_news.py
@@ -56,7 +56,8 @@ class NewsManager(object):
if os.path.exists(self.TIMESTAMP_PATH):
# Make sure the timestamp has correct permissions.
- apply_permissions( unreadfile, 0, portage_gid, 664 )
+ apply_permissions( filename=self.TIMESTAMP_FILE,
+ uid=self.config["PORTAGE_INST_UID"], gid=portage_gid, mode=664 )
timestamp = os.stat(self.TIMESTAMP_PATH).st_mtime
else:
timestamp = 0
@@ -87,14 +88,17 @@ class NewsManager(object):
path = os.path.join( self.UNREAD_PATH, "news-" + repoid + ".unread" )
try:
unread_lock = lockfile( path )
+ if not os.path.exists( path ):
+ #create the file if it does not exist
+ open( path, "w" )
+ # Ensure correct perms on the unread file.
+ apply_permissions( filename=path,
+ uid=self.config["PORTAGE_INST_UID"], gid=portage_gid, mode=664 )
# Make sure we have the correct permissions when created
unread_file = open( path, "a" )
- apply_permissions( filename=unreadfile,
- uid=self.config["PORTAGE_INST_UID"], gid=portage_gid, mode=664 )
-
+
for item in updates:
unread_file.write( item.path + "\n" )
-
unread_file.close()
finally:
unlockfile(unread_lock)
@@ -111,26 +115,22 @@ class NewsManager(object):
check for new items.
"""
- unreadfile = os.path.join( self.UNREAD_PATH, "news-"+ repoid +".unread" )
- # Set correct permissions on the news-repoid.unread file
- try:
- lock = lockfile(unreadfile)
- apply_permissions( filename=unreadfile,
- uid=self.config["PORTAGE_INST_UID"], gid=portage_gid, mode=664 )
- except FileNotFound:
- pass # It may not exist yet, thats ok.
- finally:
- if lock:
- unlockfile(lock)
if update:
self.updateItems( repoid )
+ unreadfile = os.path.join( self.UNREAD_PATH, "news-"+ repoid +".unread" )
try:
unread_lock = lockfile(unreadfile)
+ # Set correct permissions on the news-repoid.unread file
+ apply_permissions( filename=unreadfile,
+ uid=self.config["PORTAGE_INST_UID"], gid=portage_gid, mode=664 )
+
if os.path.exists( unreadfile ):
unread = open( unreadfile ).readlines()
if len(unread):
return len(unread)
+ except FileNotFound:
+ pass # unread file may not exist
finally:
if unread_lock:
unlockfile(unread_lock)