From 65d0a9b2e6b717607bf9645134703edb793d13ed Mon Sep 17 00:00:00 2001 From: Daniel Markstedt Date: Sat, 13 Nov 2021 17:38:01 -0800 Subject: [PATCH] Improved properties unzip handling (#447) * Attempt to unzip a properties file when unzipping individual files * Don't show the unzip button for properties files * Hide properties files in zip files, and show an asterisk for images with associated properties * Cleanup * Have properties files expand below images in archives * Hide bullets * Improve layout --- src/web/file_cmds.py | 13 +++++++------ src/web/settings.py | 2 +- src/web/templates/index.html | 27 ++++++++++++++++++++++----- 3 files changed, 30 insertions(+), 12 deletions(-) diff --git a/src/web/file_cmds.py b/src/web/file_cmds.py index b3a6faf3..a7b0af8a 100644 --- a/src/web/file_cmds.py +++ b/src/web/file_cmds.py @@ -190,17 +190,18 @@ def unzip_file(file_name, member=False, members=False): name = PurePath(path).name rename_file(f"{server_info['image_dir']}/{name}", f"{CFG_DIR}/{name}") prop_flag = True - elif member.endswith(PROPERTIES_SUFFIX): - unzip_proc = run( - ["unzip", "-d", CFG_DIR, "-n", "-j", \ - f"{server_info['image_dir']}/{file_name}", escape(member)], capture_output=True - ) - prop_flag = True else: unzip_proc = run( ["unzip", "-d", server_info["image_dir"], "-n", "-j", \ f"{server_info['image_dir']}/{file_name}", escape(member)], capture_output=True ) + # Attempt to unzip a properties file in the same archive dir + unzip_prop = run( + ["unzip", "-d", CFG_DIR, "-n", "-j", \ + f"{server_info['image_dir']}/{file_name}", escape(member) + "." + PROPERTIES_SUFFIX], capture_output=False + ) + if unzip_prop.returncode == 0: + prop_flag = True if unzip_proc.returncode != 0: stderr = unzip_proc.stderr.decode("utf-8") logging.warning("Unzipping failed: %s", stderr) diff --git a/src/web/settings.py b/src/web/settings.py index bedc21a6..4725ef58 100644 --- a/src/web/settings.py +++ b/src/web/settings.py @@ -7,7 +7,7 @@ from os import getenv, getcwd WEB_DIR = getcwd() # There may be a more elegant way to get the HOME dir of the user that installed RaSCSI HOME_DIR = "/".join(WEB_DIR.split("/")[0:3]) -CFG_DIR = f"{HOME_DIR}/.config/rascsi/" +CFG_DIR = f"{HOME_DIR}/.config/rascsi" AFP_DIR = f"{HOME_DIR}/afpshare" MAX_FILE_SIZE = getenv("MAX_FILE_SIZE", str(1024 * 1024 * 1024 * 4)) # 4gb diff --git a/src/web/templates/index.html b/src/web/templates/index.html index 5fa7877b..2f21fb18 100644 --- a/src/web/templates/index.html +++ b/src/web/templates/index.html @@ -175,12 +175,12 @@ {{ file["name"] }} -