Now we re-run CachedPathID.init in an 'append' mode, rather than
starting over from scratch. This avoids problems like
======================================================================
ERROR: Should not be able to add children to non-directories.
----------------------------------------------------------------------
Traceback (most recent call last):
File ".../be.wtk/libbe/storage/base.py", line 680, in test_add_invalid_directory
self.s.add('child', 'parent', directory=False)
File ".../be.wtk/libbe/storage/base.py", line 248, in add
self._add(id, *args, **kwargs)
File ".../be.wtk/libbe/storage/vcs/base.py", line 737, in _add
path = self._cached_path_id.add_id(id, parent)
File ".../be.wtk/libbe/storage/vcs/base.py", line 267, in add_id
parent_path = self.path(parent, relpath=True)
File ".../be.wtk/libbe/storage/vcs/base.py", line 246, in path
raise InvalidID(uuid)
InvalidID: parent in revision None
and similar.
self._cache_path = os.path.join(
self._root, self._spacer_dirs[0], 'id-cache')
- def init(self, verbose=True):
+ def init(self, verbose=True, cache=None):
"""
Create cache file for an existing .be directory.
File if multiple lines of the form:
UUID\tPATH
"""
- self._cache = {}
+ if cache == None:
+ self._cache = {}
+ else:
+ self._cache = cache
spaced_root = os.path.join(self._root, self._spacer_dirs[0])
for dirpath, dirnames, filenames in os.walk(spaced_root):
if dirpath == spaced_root:
self._cache[id] = relpath
except InvalidPath:
pass
- self._changed = True
- self.disconnect()
+ if self._cache != cache:
+ self._changed = True
+ if cache == None:
+ self.disconnect()
def destroy(self):
if os.path.exists(self._cache_path):
else:
extra = fields[1:]
if uuid not in self._cache:
- self.disconnect()
- self.init(verbose=False)
- self.connect()
+ self.init(verbose=False, cache=self._cache)
if uuid not in self._cache:
raise InvalidID(uuid)
if relpath == True: