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