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

[minion-cvs] Behave better when _overwriteFile gets a nonexistant fi...



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

Modified Files:
	Common.py 
Log Message:
Behave better when _overwriteFile gets a nonexistant file, or a file that is deleted out from under us.

Index: Common.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/Common.py,v
retrieving revision 1.124
retrieving revision 1.125
diff -u -d -r1.124 -r1.125
--- Common.py	8 Dec 2003 06:37:15 -0000	1.124
+++ Common.py	18 Dec 2003 23:01:47 -0000	1.125
@@ -682,14 +682,20 @@
         sz = _BLKSIZEMAP[parent]
     except KeyError:
         if hasattr(os, 'statvfs'):
-            sz = os.statvfs(f)[statvfs.F_BSIZE]
+            try:
+                sz = os.statvfs(parent)[statvfs.F_BSIZE]
+            except OSError:
+                sz = 8192 # Should be a safe guess? (????)
         else:
             sz = 8192 # Should be a safe guess? (????)
         _BLKSIZEMAP[parent] = sz
         if sz > len(_NILSTR):
             _NILSTR = '\x00' * sz
     nil = _NILSTR[:sz]
-    fd = os.open(f, os.O_WRONLY|O_BINARY)
+    try:
+        fd = os.open(f, os.O_WRONLY|O_BINARY)
+    except OSError:
+        return
     try:
         size = os.fstat(fd)[stat.ST_SIZE]
         blocks = ceilDiv(size, sz)