From: Brian Warner Date: Fri, 18 Apr 2008 03:06:06 +0000 (-0700) Subject: dirnode: return to 'delete fails if the child wasn't actually there' semantics, to... X-Git-Tag: allmydata-tahoe-1.1.0~225 X-Git-Url: https://git.rkrishnan.org/uri//%22%22?a=commitdiff_plain;h=d7b82f73c51c9ba14cdff34fb08e0326f242b4b8;p=tahoe-lafs%2Ftahoe-lafs.git dirnode: return to 'delete fails if the child wasn't actually there' semantics, to make tests pass. There's a switch to enable/disable this --- diff --git a/src/allmydata/dirnode.py b/src/allmydata/dirnode.py index 1b191c9b..99379779 100644 --- a/src/allmydata/dirnode.py +++ b/src/allmydata/dirnode.py @@ -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] diff --git a/src/allmydata/test/common.py b/src/allmydata/test/common.py index e408a56d..be7f0b9e 100644 --- a/src/allmydata/test/common.py +++ b/src/allmydata/test/common.py @@ -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():