diff --git a/catcli/catcli.py b/catcli/catcli.py index 8d9d205..431c195 100755 --- a/catcli/catcli.py +++ b/catcli/catcli.py @@ -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 diff --git a/catcli/noder.py b/catcli/noder.py index 34bb52d..8b793b4 100644 --- a/catcli/noder.py +++ b/catcli/noder.py @@ -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'''