[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[minion-cvs] Bugfix: If an error or crash occured while writing meta...



Update of /home/minion/cvsroot/src/minion/lib/mixminion
In directory moria.mit.edu:/tmp/cvs-serv14147/lib/mixminion

Modified Files:
	Filestore.py 
Log Message:
Bugfix: If an error or crash occured while writing metadata, the
server would crash every time you tried to replace it.



Index: Filestore.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/Filestore.py,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- Filestore.py	3 Jan 2004 07:35:23 -0000	1.17
+++ Filestore.py	25 Apr 2004 00:22:37 -0000	1.18
@@ -42,12 +42,6 @@
 # ======================================================================
 # Filestores.
 
-# Mode to pass to open(2) for creating a new file, and dying if it already
-# exists.
-_NEW_FILE_FLAGS = os.O_WRONLY+os.O_CREAT+os.O_EXCL
-# On windows or (old-school) mac, binary != text.
-_NEW_FILE_FLAGS += getattr(os, 'O_BINARY', 0)
-
 # Any inp_* files older than INPUT_TIMEOUT seconds old are assumed to be
 # trash.
 INPUT_TIMEOUT = 6000
@@ -437,10 +431,13 @@
 
     def setMetadata(self, handle, object):
         """Change the metadata associated with a given handle."""
+        # On windows or (old-school) mac, binary != text.
+        O_BINARY = getattr(os, 'O_BINARY', 0)
+        flags = os.O_WRONLY|os.O_CREAT|os.O_TRUNC|O_BINARY
         try:
             self._lock.acquire()
             fname = os.path.join(self.dir, "inpm_"+handle)
-            f = os.fdopen(os.open(fname, _NEW_FILE_FLAGS, 0600), "wb")
+            f = os.fdopen(os.open(fname, flags, 0600), "wb")
             cPickle.dump(object, f, 1)
             self.finishMessage(f, handle, _ismeta=1)
             self._metadata_cache[handle] = object