[Assorted-commits] SF.net SVN: assorted: [235] python-commons/trunk/src/commons/files.py
Brought to you by:
yangzhang
|
From: <yan...@us...> - 2008-01-17 23:57:19
|
Revision: 235
http://assorted.svn.sourceforge.net/assorted/?rev=235&view=rev
Author: yangzhang
Date: 2008-01-17 15:57:23 -0800 (Thu, 17 Jan 2008)
Log Message:
-----------
fixed accidental wiping out of read-file in persistent disk double buffer
Modified Paths:
--------------
python-commons/trunk/src/commons/files.py
Modified: python-commons/trunk/src/commons/files.py
===================================================================
--- python-commons/trunk/src/commons/files.py 2008-01-17 23:41:52 UTC (rev 234)
+++ python-commons/trunk/src/commons/files.py 2008-01-17 23:57:23 UTC (rev 235)
@@ -86,18 +86,18 @@
writing, and a facility for swapping the two roles is provided.
"""
def __init__( self, path_base, do_persist = True ):
- self.paths = [ path_base + '.0', path_base + '.1' ]
+ self.paths = map( path, [ path_base + '.0', path_base + '.1' ] )
self.do_persist = do_persist
self.switch_status = path( path_base + '.switched' )
if not do_persist or not self.switch_status.exists():
self.w, self.r = 0, 1 # default
else:
self.w, self.r = 1, 0
- # initialize empty reader file
- with file( self.paths[ self.r ], 'w' ): pass
self.reload_files()
def reload_files( self ):
self.writer = file( self.paths[ self.w ], 'w' )
+ if not self.paths[ self.r ].exists():
+ self.paths[ self.r ].touch()
self.reader = file( self.paths[ self.r ] )
def switch( self ):
self.close()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|