Commit 7e60a9b4 authored by Jim Fulton's avatar Jim Fulton

When packing file storages with blobs, don't hold the commit lock

while cleaning up removed blob files.

Also refactored the code slightly for clarity.
parent 54642b0b
...@@ -14,6 +14,9 @@ Bugs Fixed ...@@ -14,6 +14,9 @@ Bugs Fixed
- Officially deprecated PersistentDict - Officially deprecated PersistentDict
(https://bugs.launchpad.net/zodb/+bug/400775) (https://bugs.launchpad.net/zodb/+bug/400775)
- Small optimization of packing file storages with blobs.
3.9.0b5 (2009-08-06) 3.9.0b5 (2009-08-06)
==================== ====================
......
...@@ -1148,7 +1148,9 @@ class FileStorage( ...@@ -1148,7 +1148,9 @@ class FileStorage(
self._save_index() self._save_index()
if self.blob_dir: if self.blob_dir:
self._move_unpacked_blobs() self._commit_lock_release()
have_commit_lock = False
self._remove_blob_files_tagged_for_removal_during_pack()
finally: finally:
self._lock_release() self._lock_release()
finally: finally:
...@@ -1158,9 +1160,8 @@ class FileStorage( ...@@ -1158,9 +1160,8 @@ class FileStorage(
self._pack_is_in_progress = False self._pack_is_in_progress = False
self._lock_release() self._lock_release()
def _move_unpacked_blobs(self):
# Move any blobs linked or copied while packing to the def _remove_blob_files_tagged_for_removal_during_pack(self):
# pack dir, which will become the old dir
lblob_dir = len(self.blob_dir) lblob_dir = len(self.blob_dir)
fshelper = self.fshelper fshelper = self.fshelper
old = self.blob_dir+'.old' old = self.blob_dir+'.old'
...@@ -1181,10 +1182,11 @@ class FileStorage( ...@@ -1181,10 +1182,11 @@ class FileStorage(
link_or_copy(os.path.join(self.blob_dir, '.layout'), link_or_copy(os.path.join(self.blob_dir, '.layout'),
os.path.join(old, '.layout')) os.path.join(old, '.layout'))
def handle_file(path): def handle_file(path):
dest = os.path.dirname(old+path[lblob_dir:]) newpath = old+path[lblob_dir:]
dest = os.path.dirname(newpath)
if not os.path.exists(dest): if not os.path.exists(dest):
os.makedirs(dest, 0700) os.makedirs(dest, 0700)
os.rename(path, old+path[lblob_dir:]) os.rename(path, newpath)
handle_dir = handle_file handle_dir = handle_file
else: else:
# Helpers that remove an oid dir or revision file. # Helpers that remove an oid dir or revision file.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment