]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
dirnode: return to 'delete fails if the child wasn't actually there' semantics, to...
authorBrian Warner <warner@allmydata.com>
Fri, 18 Apr 2008 03:06:06 +0000 (20:06 -0700)
committerBrian Warner <warner@allmydata.com>
Fri, 18 Apr 2008 03:06:06 +0000 (20:06 -0700)
src/allmydata/dirnode.py
src/allmydata/test/common.py

index 1b191c9bfabee6f638fce11a9f0257f2f4f05803..99379779f33eb820082358c432ee5ded4aa0828a 100644 (file)
@@ -39,12 +39,15 @@ def split_netstring(data, numstrings, allow_leftover=False):
     return tuple(elements)
 
 class Deleter:
-    def __init__(self, node, name):
+    def __init__(self, node, name, must_exist=True):
         self.node = node
         self.name = name
+        self.must_exist = True
     def modify(self, old_contents):
         children = self.node._unpack_contents(old_contents)
         if self.name not in children:
+            if self.must_exist:
+                raise KeyError(self.name)
             self.old_child = None
             return None
         self.old_child, metadata = children[self.name]
index e408a56d6b1c9dc0be4c1c0a285d32e530db2b69..be7f0b9ecda321fa663cccae1f8db08a6b2b256f 100644 (file)
@@ -102,10 +102,12 @@ class FakeMutableFileNode:
         self.all_contents[self.storage_index] = new_contents
         return defer.succeed(None)
     def modify(self, modifier):
+        return defer.maybeDeferred(self._modify, modifier)
+    def _modify(self, modifier):
         assert not self.is_readonly()
         old_contents = self.all_contents[self.storage_index]
         self.all_contents[self.storage_index] = modifier(old_contents)
-        return defer.succeed(None)
+        return None
 
 
 def make_mutable_file_uri():