+ def add_path(self, path):
+ self.paths.append(path)
+ logging.debug('Added path "%s" to the list' % path)
+
+ def store_cache(self, filename):
+ try:
+ fd = open(filename, 'wb')
+ pickle.dump(self, fd, 2)
+ logging.debug("Cache successfully stored")
+ except Exception, e:
+ logging.warning("Storing cache", exc_info=1)
+
+ def load_cache(self, filename, rescanPaths = False):
+ logging.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:
+ logging.debug("Path lists match, copying properties")
+ # Overwrite this object with the other
+ for attr in ('list', 'imagePointer', 'favourites'):
+ setattr(self, attr, getattr(tmp, attr))
+ else:
+ logging.debug("Ignoring cache, path lists do not match")
+ except Exception, e:
+ logging.warning("Loading cache", exc_info=1)
+ else:
+ return True
+