- def add_path(self, path):
- self.paths.append(path)
- debug('Added path "%s" to the list' % path)
-
- def store_cache(self, filename):
- try:
- fd = open(filename, 'wb')
- pickle.dump(obj = self, file = fd, protocol = 2)
- debug("Cache successfully stored")
- except Exception, e:
- warning("Storing cache: %s" % e)
-
- def load_cache(self, filename, rescanPaths = False):
- debug('Attempting to load cache from "%s"' % filename)
- self.paths.sort()
- try:
- fd = open(filename, 'rb')
- tmp = pickle.load(fd)
- if self.paths == tmp.paths:
- debug("Path lists match, copying properties")
- # Overwrite this object with the other
- for attr in ('list', 'imagePointer'):
- setattr(self, attr, getattr(tmp, attr))
- else:
- debug("Ignoring cache, path lists do not match")
- except Exception, e:
- warning("Loading cache: %s" % e)
-