consolidator: add more verbose traversal of directories
This commit is contained in:
parent
760688a224
commit
1c24707f19
|
@ -222,7 +222,7 @@ class Consolidator:
|
||||||
# readonly directory (which shares common subdirs with previous
|
# readonly directory (which shares common subdirs with previous
|
||||||
# backups)
|
# backups)
|
||||||
self.msg(" %s: processing" % rwname)
|
self.msg(" %s: processing" % rwname)
|
||||||
readcap = self.process_directory(readonly(writecap))
|
readcap = self.process_directory(readonly(writecap), (rwname,))
|
||||||
if self.options["really"]:
|
if self.options["really"]:
|
||||||
self.msg(" replaced %s" % rwname)
|
self.msg(" replaced %s" % rwname)
|
||||||
self.put_child(archives_dircap, rwname, readcap)
|
self.put_child(archives_dircap, rwname, readcap)
|
||||||
|
@ -241,7 +241,7 @@ class Consolidator:
|
||||||
% (self.directories_created, self.directories_used_as_is,
|
% (self.directories_created, self.directories_used_as_is,
|
||||||
self.directories_reused))
|
self.directories_reused))
|
||||||
|
|
||||||
def process_directory(self, readcap):
|
def process_directory(self, readcap, path):
|
||||||
# I walk all my children (recursing over any subdirectories), build
|
# I walk all my children (recursing over any subdirectories), build
|
||||||
# up a table of my contents, then see if I can re-use an old
|
# up a table of my contents, then see if I can re-use an old
|
||||||
# directory with the same contents. If not, I create a new directory
|
# directory with the same contents. If not, I create a new directory
|
||||||
|
@ -257,7 +257,9 @@ class Consolidator:
|
||||||
for (childname, (childtype, childdata)) in sorted(data["children"].items()):
|
for (childname, (childtype, childdata)) in sorted(data["children"].items()):
|
||||||
if childtype == "dirnode":
|
if childtype == "dirnode":
|
||||||
num_dirs += 1
|
num_dirs += 1
|
||||||
childcap = self.process_directory(str(childdata["ro_uri"]))
|
childpath = path + (childname,)
|
||||||
|
childcap = self.process_directory(str(childdata["ro_uri"]),
|
||||||
|
childpath)
|
||||||
contents[childname] = ("dirnode", childcap, None)
|
contents[childname] = ("dirnode", childcap, None)
|
||||||
else:
|
else:
|
||||||
childcap = str(childdata["ro_uri"])
|
childcap = str(childdata["ro_uri"])
|
||||||
|
@ -267,17 +269,23 @@ class Consolidator:
|
||||||
dirhash = self.hash_directory_contents(hashkids)
|
dirhash = self.hash_directory_contents(hashkids)
|
||||||
old_dircap = self.get_old_dirhash(dirhash)
|
old_dircap = self.get_old_dirhash(dirhash)
|
||||||
if old_dircap:
|
if old_dircap:
|
||||||
|
if self.options["verbose"]:
|
||||||
|
self.msg(" %s: reused" % "/".join(path))
|
||||||
assert isinstance(old_dircap, str)
|
assert isinstance(old_dircap, str)
|
||||||
self.directories_reused += 1
|
self.directories_reused += 1
|
||||||
return old_dircap
|
return old_dircap
|
||||||
if num_dirs == 0:
|
if num_dirs == 0:
|
||||||
# we're allowed to re-use this directory
|
# we're allowed to use this directory as-is
|
||||||
|
if self.options["verbose"]:
|
||||||
|
self.msg(" %s: used as-is" % "/".join(path))
|
||||||
new_dircap = readonly(readcap)
|
new_dircap = readonly(readcap)
|
||||||
assert isinstance(new_dircap, str)
|
assert isinstance(new_dircap, str)
|
||||||
self.store_dirhash(dirhash, new_dircap)
|
self.store_dirhash(dirhash, new_dircap)
|
||||||
self.directories_used_as_is += 1
|
self.directories_used_as_is += 1
|
||||||
return new_dircap
|
return new_dircap
|
||||||
# otherwise, we need to create a new directory
|
# otherwise, we need to create a new directory
|
||||||
|
if self.options["verbose"]:
|
||||||
|
self.msg(" %s: created" % "/".join(path))
|
||||||
new_dircap = readonly(self.mkdir(contents))
|
new_dircap = readonly(self.mkdir(contents))
|
||||||
assert isinstance(new_dircap, str)
|
assert isinstance(new_dircap, str)
|
||||||
self.store_dirhash(dirhash, new_dircap)
|
self.store_dirhash(dirhash, new_dircap)
|
||||||
|
|
|
@ -768,6 +768,7 @@ class ConsolidateOptions(VDriveOptions):
|
||||||
]
|
]
|
||||||
optFlags = [
|
optFlags = [
|
||||||
("really", None, "Really remove old snapshot directories"),
|
("really", None, "Really remove old snapshot directories"),
|
||||||
|
("verbose", "v", "Emit a line for every directory examined"),
|
||||||
]
|
]
|
||||||
def parseArgs(self, where):
|
def parseArgs(self, where):
|
||||||
self.where = where
|
self.where = where
|
||||||
|
|
|
@ -170,6 +170,7 @@ class Consolidate(GridTestMixin, CLITestMixin, unittest.TestCase):
|
||||||
self.do_cli_good("debug", "consolidate",
|
self.do_cli_good("debug", "consolidate",
|
||||||
"--dbfile", dbfile,
|
"--dbfile", dbfile,
|
||||||
"--backupfile", backupfile,
|
"--backupfile", backupfile,
|
||||||
|
"--verbose",
|
||||||
"tahoe:"))
|
"tahoe:"))
|
||||||
def _check_consolidate_output1(out):
|
def _check_consolidate_output1(out):
|
||||||
lines = out.splitlines()
|
lines = out.splitlines()
|
||||||
|
|
Loading…
Reference in New Issue