mirror of
https://github.com/borgbackup/borg.git
synced 2024-12-24 16:55:36 +00:00
Add msgpack-python >= 0.3 compatibility
This commit is contained in:
parent
49744c0457
commit
1dc1411302
3 changed files with 10 additions and 10 deletions
|
@ -132,7 +132,7 @@ def __repr__(self):
|
|||
return 'Archive(%r)' % self.name
|
||||
|
||||
def iter_items(self, filter=None):
|
||||
unpacker = msgpack.Unpacker()
|
||||
unpacker = msgpack.Unpacker(use_list=False)
|
||||
i = 0
|
||||
n = 20
|
||||
while True:
|
||||
|
@ -205,7 +205,7 @@ def add(id):
|
|||
self.cache.chunks[id] = count - 1, size, csize
|
||||
# This function is a bit evil since it abuses the cache to calculate
|
||||
# the stats. The cache transaction must be rolled back afterwards
|
||||
unpacker = msgpack.Unpacker()
|
||||
unpacker = msgpack.Unpacker(use_list=False)
|
||||
cache.begin_txn()
|
||||
stats = Statistics()
|
||||
add(self.id)
|
||||
|
@ -319,7 +319,7 @@ def verify_file(self, item, start, result, peek=None):
|
|||
result(item, True)
|
||||
|
||||
def delete(self, cache):
|
||||
unpacker = msgpack.Unpacker()
|
||||
unpacker = msgpack.Unpacker(use_list=False)
|
||||
for id in self.metadata['items']:
|
||||
unpacker.feed(self.key.decrypt(id, self.store.get(id)))
|
||||
for item in unpacker:
|
||||
|
|
|
@ -63,15 +63,15 @@ def _read_files(self):
|
|||
self.files = {}
|
||||
self._newest_mtime = 0
|
||||
with open(os.path.join(self.path, 'files'), 'rb') as fd:
|
||||
u = msgpack.Unpacker()
|
||||
u = msgpack.Unpacker(use_list=True)
|
||||
while True:
|
||||
data = fd.read(64 * 1024)
|
||||
if not data:
|
||||
break
|
||||
u.feed(data)
|
||||
for hash, item in u:
|
||||
if item[0] < 10:
|
||||
self.files[hash] = (item[0] + 1,) + item[1:]
|
||||
item[0] += 1
|
||||
self.files[hash] = item
|
||||
|
||||
def begin_txn(self):
|
||||
# Initialize transaction snapshot
|
||||
|
@ -94,7 +94,7 @@ def commit(self):
|
|||
for item in self.files.iteritems():
|
||||
# Discard cached files with the newest mtime to avoid
|
||||
# issues with filesystem snapshots and mtime precision
|
||||
if item[1][3] < self._newest_mtime:
|
||||
if item[1][0] < 10 and item[1][3] < self._newest_mtime:
|
||||
msgpack.pack(item, fd)
|
||||
self.config.set('cache', 'manifest', self.manifest.id.encode('hex'))
|
||||
with open(os.path.join(self.path, 'config'), 'w') as fd:
|
||||
|
@ -192,7 +192,7 @@ def file_known_and_unchanged(self, path_hash, st):
|
|||
if (entry and entry[3] == st.st_mtime
|
||||
and entry[2] == st.st_size and entry[1] == st.st_ino):
|
||||
# reset entry age
|
||||
self.files[path_hash] = (0,) + entry[1:]
|
||||
self.files[path_hash][0] = 0
|
||||
return entry[4]
|
||||
else:
|
||||
return None
|
||||
|
|
|
@ -26,7 +26,7 @@ def serve(self):
|
|||
# Make stdout blocking
|
||||
fl = fcntl.fcntl(sys.stdout.fileno(), fcntl.F_GETFL)
|
||||
fcntl.fcntl(sys.stdout.fileno(), fcntl.F_SETFL, fl & ~os.O_NONBLOCK)
|
||||
unpacker = msgpack.Unpacker()
|
||||
unpacker = msgpack.Unpacker(use_list=False)
|
||||
while True:
|
||||
r, w, es = select.select([sys.stdin], [], [], 10)
|
||||
if r:
|
||||
|
@ -71,7 +71,7 @@ def __init__(self, location, create=False):
|
|||
self.to_send = ''
|
||||
self.extra = {}
|
||||
self.pending = {}
|
||||
self.unpacker = msgpack.Unpacker()
|
||||
self.unpacker = msgpack.Unpacker(use_list=False)
|
||||
self.msgid = 0
|
||||
self.received_msgid = 0
|
||||
args = ['ssh', '-p', str(location.port), '%s@%s' % (location.user or getpass.getuser(), location.host), 'darc', 'serve']
|
||||
|
|
Loading…
Reference in a new issue