From 620fca54727e37ba1b3e5ba745fdd7d7186dcafd Mon Sep 17 00:00:00 2001 From: Elrond Date: Mon, 8 Aug 2011 21:51:11 +0200 Subject: [PATCH] MountStorage: Improve mounting asserts The asserts now differentiate between mounting on the same path and mounting over a shorter path. --- mediagoblin/storage.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/mediagoblin/storage.py b/mediagoblin/storage.py index bbf1c034..88c748ce 100644 --- a/mediagoblin/storage.py +++ b/mediagoblin/storage.py @@ -313,13 +313,16 @@ class MountStorage(StorageInterface): print "Mounting:", repr(new_ent) already, rem_1, table, rem_2 = self._resolve_to_backend(new_ent, True) - print "===", repr(already), repr(rem_1), repr(rem_2) + print "===", repr(already), repr(rem_1), repr(rem_2), len(table) + + assert (len(rem_2) > 0) or (None not in table), \ + "That path is already mounted" + assert (len(rem_2) > 0) or (len(table)==0), \ + "A longer path is already mounted here" - assert (already is None) or (len(rem_2) > 0), "Already mounted" for part in rem_2: table[part] = {} table = table[part] - assert not table.has_key(None), "Huh? Already mounted?!" table[None] = backend def _resolve_to_backend(self, filepath, extra_info = False): -- 2.25.1