Commit 7206fb92 authored by Jim Fulton's avatar Jim Fulton

Make sure temporary storage is closed, even if there is an error while

committing.
parent 6a67ef86
...@@ -1167,34 +1167,38 @@ class Connection(ExportImport, object): ...@@ -1167,34 +1167,38 @@ class Connection(ExportImport, object):
self._storage = self._normal_storage self._storage = self._normal_storage
self._savepoint_storage = None self._savepoint_storage = None
self._log.debug("Committing savepoints of size %s", src.getSize()) try:
oids = src.index.keys() self._log.debug("Committing savepoints of size %s", src.getSize())
oids = src.index.keys()
# Copy invalidating and creating info from temporary storage:
self._modified.extend(oids) # Copy invalidating and creating info from temporary storage:
self._creating.update(src.creating) self._modified.extend(oids)
self._creating.update(src.creating)
for oid in oids:
data, serial = src.load(oid, src) for oid in oids:
obj = self._cache.get(oid, None) data, serial = src.load(oid, src)
if obj is not None: obj = self._cache.get(oid, None)
self._cache.update_object_size_estimation(obj._p_oid, len(data)) if obj is not None:
obj._p_estimated_size = len(data) self._cache.update_object_size_estimation(
if isinstance(self._reader.getGhost(data), Blob): obj._p_oid, len(data))
blobfilename = src.loadBlob(oid, serial) obj._p_estimated_size = len(data)
s = self._storage.storeBlob(oid, serial, data, blobfilename, if isinstance(self._reader.getGhost(data), Blob):
blobfilename = src.loadBlob(oid, serial)
s = self._storage.storeBlob(
oid, serial, data, blobfilename,
'', transaction)
# we invalidate the object here in order to ensure
# that that the next attribute access of its name
# unghostify it, which will cause its blob data
# to be reattached "cleanly"
self.invalidate(None, (oid, ))
else:
s = self._storage.store(oid, serial, data,
'', transaction) '', transaction)
# we invalidate the object here in order to ensure
# that that the next attribute access of its name
# unghostify it, which will cause its blob data
# to be reattached "cleanly"
self.invalidate(None, (oid, ))
else:
s = self._storage.store(oid, serial, data,
'', transaction)
self._handle_serial(s, oid, change=False) self._handle_serial(s, oid, change=False)
src.close() finally:
src.close()
def _abort_savepoint(self): def _abort_savepoint(self):
"""Discard all savepoint data.""" """Discard all savepoint data."""
......
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