Commit e5dbf27c authored by Christian Theune's avatar Christian Theune

- added test for special undo situation

 - added small non-yet-working work-around
parent 6a667c11
......@@ -193,14 +193,20 @@ class BlobStorage(ProxyBase):
return orig_size + blob_size
def undo(self, serial_id, transaction):
import pdb; pdb.set_trace()
serial, keys = getProxiedObject(self).undo(serial_id, transaction)
self._lock_acquire()
try:
# The old serial_id is given in base64 encoding ...
serial_id = base64.decodestring(serial_id+ '\n')
for oid in self.fshelper.getOIDsForSerial(serial_id):
data, serial_before, serial_after = self.loadBefore(oid,
serial_id)
load_result = self.loadBefore(oid, serial_id)
if load_result is None:
continue
data, serial_before, serial_after = load_result
orig_fn = self.fshelper.getBlobFilename(oid, serial_before)
orig = open(orig_fn, "r")
new_fn = self.fshelper.getBlobFilename(oid, serial)
......
......@@ -37,6 +37,26 @@ class BlobUndoTests(unittest.TestCase):
pass
shutil.rmtree(self.blob_dir)
def testUndoWithoutPreviousVersion(self):
base_storage = FileStorage(self.storagefile)
blob_storage = BlobStorage(self.blob_dir, base_storage)
database = DB(blob_storage)
connection = database.open()
root = connection.root()
transaction.begin()
blob = Blob()
blob.open('w').write('this is state 1')
root['blob'] = blob
transaction.commit()
serial = base64.encodestring(blob_storage._tid)
transaction.begin()
blob_storage.undo(serial, blob_storage._transaction)
transaction.commit()
self.assertRaises(KeyError, root.__getitem__, 'blob')
def testUndo(self):
base_storage = FileStorage(self.storagefile)
blob_storage = BlobStorage(self.blob_dir, base_storage)
......
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