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