1
0
Fork 0
mirror of https://github.com/borgbackup/borg.git synced 2025-02-12 09:30:27 +00:00

Open cache/files on demand

This commit is contained in:
Jonas Borgström 2011-07-02 20:39:35 +02:00
parent 785ba396bb
commit 0680c0a24f

View file

@ -60,8 +60,10 @@ def open(self):
self.id = self.config.get('cache', 'store_id').decode('hex') self.id = self.config.get('cache', 'store_id').decode('hex')
self.tid = self.config.getint('cache', 'tid') self.tid = self.config.getint('cache', 'tid')
self.chunks = NSIndex(os.path.join(self.path, 'chunks')) self.chunks = NSIndex(os.path.join(self.path, 'chunks'))
self.files = {}
def _read_files(self):
with open(os.path.join(self.path, 'files'), 'rb') as fd: with open(os.path.join(self.path, 'files'), 'rb') as fd:
self.files = {}
u = msgpack.Unpacker() u = msgpack.Unpacker()
while True: while True:
data = fd.read(64 * 1024) data = fd.read(64 * 1024)
@ -168,6 +170,8 @@ def chunk_decref(self, id):
self.chunks[id] = (count - 1, size) self.chunks[id] = (count - 1, size)
def file_known_and_unchanged(self, path_hash, st): def file_known_and_unchanged(self, path_hash, st):
if not self.files:
self._read_files()
entry = self.files.get(path_hash) entry = self.files.get(path_hash)
if (entry and entry[3] == st.st_mtime if (entry and entry[3] == st.st_mtime
and entry[2] == st.st_size and entry[1] == st.st_ino): and entry[2] == st.st_size and entry[1] == st.st_ino):