mirror of
https://github.com/borgbackup/borg.git
synced 2025-02-12 17:35:44 +00:00
Open cache/files on demand
This commit is contained in:
parent
785ba396bb
commit
0680c0a24f
1 changed files with 5 additions and 1 deletions
|
@ -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'))
|
||||||
with open(os.path.join(self.path, 'files'), 'rb') as fd:
|
|
||||||
self.files = {}
|
self.files = {}
|
||||||
|
|
||||||
|
def _read_files(self):
|
||||||
|
with open(os.path.join(self.path, 'files'), 'rb') as fd:
|
||||||
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):
|
||||||
|
|
Loading…
Reference in a new issue