[Zodb-checkins] SVN: ZODB/branches/gocept-iteration/src/Z refactoring: added FilesystemHelper.createPathForOID(oid)

Thomas Lotze tl at gocept.com
Mon Apr 28 09:51:22 EDT 2008


Log message for revision 85800:
  refactoring: added FilesystemHelper.createPathForOID(oid)

Changed:
  U   ZODB/branches/gocept-iteration/src/ZEO/ClientStorage.py
  U   ZODB/branches/gocept-iteration/src/ZODB/blob.py

-=-
Modified: ZODB/branches/gocept-iteration/src/ZEO/ClientStorage.py
===================================================================
--- ZODB/branches/gocept-iteration/src/ZEO/ClientStorage.py	2008-04-28 12:19:51 UTC (rev 85799)
+++ ZODB/branches/gocept-iteration/src/ZEO/ClientStorage.py	2008-04-28 13:51:16 UTC (rev 85800)
@@ -932,14 +932,7 @@
             raise POSException.POSKeyError("No blob file", oid, serial)
 
         # First, we'll create the directory for this oid, if it doesn't exist. 
-        targetpath = self.fshelper.getPathForOID(oid)
-        if not os.path.exists(targetpath):
-            try:
-                os.makedirs(targetpath, 0700)
-            except OSError:
-                # We might have lost a race.  If so, the directory
-                # must exist now
-                assert os.path.exists(targetpath)
+        self.fshelper.createPathForOID(oid)
 
         # OK, it's not here and we (or someone) needs to get it.  We
         # want to avoid getting it multiple times.  We want to avoid

Modified: ZODB/branches/gocept-iteration/src/ZODB/blob.py
===================================================================
--- ZODB/branches/gocept-iteration/src/ZODB/blob.py	2008-04-28 12:19:51 UTC (rev 85799)
+++ ZODB/branches/gocept-iteration/src/ZODB/blob.py	2008-04-28 13:51:16 UTC (rev 85800)
@@ -324,6 +324,21 @@
         """
         return os.path.join(self.base_dir, utils.oid_repr(oid))
 
+    def createPathForOID(self, oid):
+        """Given an OID, creates a directory on the filesystem where
+        the blob data relating to that OID is stored, if it doesn't exist.
+
+        """
+        path = self.getPathForOID(oid)
+        if os.path.exists(path):
+            return
+        try:
+            os.makedirs(path, 0700)
+        except OSError:
+            # We might have lost a race.  If so, the directory
+            # must exist now
+            assert os.path.exists(path)
+
     def getBlobFilename(self, oid, tid):
         """Given an oid and a tid, return the full filename of the
         'committed' blob file related to that oid and tid.



More information about the Zodb-checkins mailing list