diff options
author | Lars Wirzenius <liw@liw.fi> | 2014-02-23 19:10:20 +0000 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2014-02-23 19:10:20 +0000 |
commit | 685eecb7ba4b315f434aaf1ffe3dc1ea1ade5336 (patch) | |
tree | f3948a5d6bc5fb13d07f884137220f1489ae448d /obnamlib/plugins/fuse_plugin.py | |
parent | 6a1a2e7de7cd9979484a8b3651453fb27ac79cae (diff) | |
download | obnam-685eecb7ba4b315f434aaf1ffe3dc1ea1ade5336.tar.gz |
Remove metadata cache
RepositoryInterface implementations are meant to do the caching
internally, for when it's useful, rather than have it in every caller.
Diffstat (limited to 'obnamlib/plugins/fuse_plugin.py')
-rw-r--r-- | obnamlib/plugins/fuse_plugin.py | 25 |
1 files changed, 9 insertions, 16 deletions
diff --git a/obnamlib/plugins/fuse_plugin.py b/obnamlib/plugins/fuse_plugin.py index 0bf338a1..e88c4c7b 100644 --- a/obnamlib/plugins/fuse_plugin.py +++ b/obnamlib/plugins/fuse_plugin.py @@ -197,13 +197,10 @@ class ObnamFuse(fuse.Fuse): '''FUSE main class.''' - MAX_METADATA_CACHE = 512 - def __init__(self, *args, **kw): self.obnam = kw['obnam'] ObnamFuseFile.fs = self self.file_class = ObnamFuseFile - self.metadatacache = {} self.sizecache = {} self.rootlist = None self.rootstat = None @@ -219,7 +216,6 @@ class ObnamFuse(fuse.Fuse): if not self.obnam.repo.get_is_checkpoint(gen)] tracing.trace('found %d generations', len(generations)) self.rootstat, self.rootlist = self.multiple_root_list(generations) - self.metadatacache.clear() except: logging.exception('Unexpected exception') raise @@ -227,18 +223,15 @@ class ObnamFuse(fuse.Fuse): def get_metadata(self, path): tracing.trace('path=%r', path) - if path not in self.metadatacache: - if len(self.metadatacache) > self.MAX_METADATA_CACHE: - self.metadatacache.clear() - metadata = self.obnam.repo.get_metadata(*self.get_gen_path(path)) - self.metadatacache[path] = metadata - # FUSE does not allow negative timestamps, truncate to zero - if metadata.st_atime_sec < 0: - metadata.st_atime_sec = 0 - if metadata.st_mtime_sec < 0: - metadata.st_mtime_sec = 0 - - return self.metadatacache[path] + metadata = self.obnam.repo.get_metadata(*self.get_gen_path(path)) + + # FUSE does not allow negative timestamps, truncate to zero + if metadata.st_atime_sec < 0: + metadata.st_atime_sec = 0 + if metadata.st_mtime_sec < 0: + metadata.st_mtime_sec = 0 + + return metadata def get_stat(self, path): tracing.trace('path=%r', path) |