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

[minion-cvs] Backport fix for inmp_* bug.



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

Modified Files:
      Tag: mixminion-v0-0-7-patches
	Filestore.py 
Log Message:
Backport fix for inmp_* bug.

Index: Filestore.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/Filestore.py,v
retrieving revision 1.17
retrieving revision 1.17.2.1
diff -u -d -r1.17 -r1.17.2.1
--- Filestore.py	3 Jan 2004 07:35:23 -0000	1.17
+++ Filestore.py	25 Apr 2004 00:25:46 -0000	1.17.2.1
@@ -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