shares with subfolders
This commit is contained in:
@@ -52,14 +52,11 @@ def list_folders(shares,config):
|
|||||||
print("data_folder not defined in config")
|
print("data_folder not defined in config")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
data_folder = os.path.join(config['__root_path__'], config['data_folder'])
|
data_folder = os.path.join(config['__root_path__'], config['data_folder'])
|
||||||
folders = sorted(os.listdir(data_folder))
|
|
||||||
table = []
|
table = []
|
||||||
table.append( ('Path','Share','Size','Unit') )
|
table.append( ('Path','Share','Size','Unit') )
|
||||||
for folder in folders:
|
for path, folders, files in os.walk(data_folder):
|
||||||
full_path = os.path.join(data_folder, folder)
|
full_path = os.path.join(data_folder, path)
|
||||||
if not os.path.isdir(full_path):
|
share_name = None
|
||||||
continue
|
|
||||||
share_name = "[unused by any share]"
|
|
||||||
for share in shares:
|
for share in shares:
|
||||||
share_path = os.path.join(data_folder, share['path'])
|
share_path = os.path.join(data_folder, share['path'])
|
||||||
if not os.path.exists(share_path):
|
if not os.path.exists(share_path):
|
||||||
@@ -67,11 +64,19 @@ def list_folders(shares,config):
|
|||||||
if os.path.samefile(full_path, share_path):
|
if os.path.samefile(full_path, share_path):
|
||||||
share_name = share['name']
|
share_name = share['name']
|
||||||
break
|
break
|
||||||
(size_num, size_unit) = file_size_human(get_folder_size(
|
if share_name == None:
|
||||||
|
# skip folder if it's not a share, and not a leaf
|
||||||
|
if len(folders) > 0:
|
||||||
|
continue
|
||||||
|
share_name = "[Unused]"
|
||||||
|
(size_num, size_unit) = file_size_human(
|
||||||
|
get_folder_size(
|
||||||
full_path
|
full_path
|
||||||
)).split(" ")
|
),
|
||||||
|
HTML=False
|
||||||
|
).split(" ",1)
|
||||||
table.append((
|
table.append((
|
||||||
folder,
|
path,
|
||||||
share_name,
|
share_name,
|
||||||
size_num,
|
size_num,
|
||||||
size_unit
|
size_unit
|
||||||
|
|||||||
Reference in New Issue
Block a user