fix bug for #15

pull/19/head
deadc0de6 3 years ago
parent 613a9092c1
commit bd5d504997

@ -90,6 +90,7 @@ def cmd_index(args, noder, catalog, top):
return
node = noder.get_storage_node(top, name)
node.parent = None
start = datetime.datetime.now()
walker = Walker(noder, hash=hash, debug=debug)
attr = noder.format_storage_attr(args['--meta'])
@ -113,7 +114,7 @@ def cmd_update(args, noder, catalog, top):
if not os.path.exists(path):
Logger.err('\"{}\" does not exist'.format(path))
return
root = noder.get_storage_node(top, name)
root = noder.get_storage_node(top, name, path=path)
if not root:
Logger.err('storage named \"{}\" does not exist'.format(name))
return

@ -53,14 +53,23 @@ class Noder:
'''return a list of all storage names'''
return [x.name for x in list(top.children)]
def get_storage_node(self, top, name):
'''return the storage node if any'''
def get_storage_node(self, top, name, path=None):
'''
return the storage node if any
if path is submitted, it will update the media info
'''
found = None
for n in top.children:
if n.type != self.TYPE_STORAGE:
continue
if n.name == name:
return n
return None
found = n
break
if found and path and os.path.exists(path):
found.free = shutil.disk_usage(path).free
found.total = shutil.disk_usage(path).total
found.ts = int(time.time())
return found
def get_node(self, top, path, quiet=False):
'''get the node by internal tree path'''

Loading…
Cancel
Save