Commit fa36368c authored by Anders Blomdell's avatar Anders Blomdell
Browse files

Use path length in space allocation

parent db98d4e2
......@@ -74,7 +74,7 @@ class Backup:
cwd = os.path.join(self.mount, self.path)
reader = tar_stream.TarReader(self.primary_out)
for e in reader:
self.make_room(e.size, e.path)
e.tarfile.extract(e, path=cwd)
......@@ -117,15 +117,17 @@ class Backup:
self.status.unchanged += 1
def make_room(self, size):
def get_free_need(size):
def make_room(self, size, path=None):
def get_free_need(size, path):
stat = os.statvfs(self.dst_root)
free = stat.f_frsize * stat.f_bavail
need = size + stat.f_frsize
if path:
need += stat.f_frsize * len(path.split('/'))
return (free, need)
do_log = False
while True:
free,need = get_free_need(size)
free,need = get_free_need(size, path)
if do_log:
self.log.MESSAGE("After, free=%d, need=%d" % (free, need))
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment