From d7b82f73c51c9ba14cdff34fb08e0326f242b4b8 Mon Sep 17 00:00:00 2001 From: Brian Warner <warner@allmydata.com> Date: Thu, 17 Apr 2008 20:06:06 -0700 Subject: [PATCH] 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 --- src/allmydata/dirnode.py | 5 ++++- src/allmydata/test/common.py | 4 +++- 2 files changed, 7 insertions(+), 2 deletions(-) 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(): -- 2.45.2