moved file delete

This commit is contained in:
2024-06-27 10:37:29 +02:00
committed by Flo Greistorfer
parent 4cd87ccb34
commit 6ea7fca0cd

View File

@@ -192,6 +192,8 @@ def listfolder(folder: str, title: str):
image += f': <a href="{args.webroot}{urllib.parse.quote(folder.removeprefix(args.root))}/{urllib.parse.quote(os.path.splitext(item)[0])}{raw.upper()}">RAW</a>' image += f': <a href="{args.webroot}{urllib.parse.quote(folder.removeprefix(args.root))}/{urllib.parse.quote(os.path.splitext(item)[0])}{raw.upper()}">RAW</a>'
image += "</figcaption></figure>" image += "</figcaption></figure>"
images.extend([image]) images.extend([image])
if os.path.exists(os.path.join(folder, "index.html")):
os.remove(os.path.join(folder, "index.html"))
if len(images) > 0 or (args.fancyfolders and not contains_files): if len(images) > 0 or (args.fancyfolders and not contains_files):
with open(os.path.join(folder, "index.html"), "w", encoding="utf-8") as f: with open(os.path.join(folder, "index.html"), "w", encoding="utf-8") as f:
f.write(temp_obj.substitute(title=title)) f.write(temp_obj.substitute(title=title))
@@ -212,9 +214,6 @@ def listfolder(folder: str, title: str):
f.write(" </div>\n") f.write(" </div>\n")
f.write(" </body>\n</html>") f.write(" </body>\n</html>")
f.close() f.close()
else:
if os.path.exists(os.path.join(folder, "index.html")):
os.remove(os.path.join(folder, "index.html"))
pbar.update(1) pbar.update(1)
@@ -264,12 +263,12 @@ def main():
gettotal(args.root) gettotal(args.root)
pbar.close() pbar.close()
pbar = tqdm(total=total + 1, desc="Generating html files", unit=" files") pbar = tqdm(total=total + 1, desc="Generating html files", unit=" files", ascii="#", dynamic_ncols=True)
listfolder(args.root, _ROOTTITLE) listfolder(args.root, _ROOTTITLE)
pbar.close() pbar.close()
with Pool(os.cpu_count()) as p: with Pool(os.cpu_count()) as p:
for r in tqdm(p.imap_unordered(thumbnail_convert, thumbnails), total=len(thumbnails), desc="Generating thumbnails", unit=" files"): for r in tqdm(p.imap_unordered(thumbnail_convert, thumbnails), total=len(thumbnails), desc="Generating thumbnails", unit=" files", ascii="#", dynamic_ncols=True):
... ...