From 9a405dd3364827858dbd05fdb3f7de6d79622c6d Mon Sep 17 00:00:00 2001 From: Sylvia Krech <40416079+Sylvia-Krech@users.noreply.github.com> Date: Thu, 2 May 2024 11:47:32 -0500 Subject: [PATCH 1/2] Fix for #120, Windows filepaths with spaces --- tagstudio/src/qt/helpers/file_opener.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tagstudio/src/qt/helpers/file_opener.py b/tagstudio/src/qt/helpers/file_opener.py index 82461242..65ab54a3 100644 --- a/tagstudio/src/qt/helpers/file_opener.py +++ b/tagstudio/src/qt/helpers/file_opener.py @@ -35,13 +35,15 @@ def open_file(path: str, file_manager: bool = False): if sys.platform == "win32": normpath = os.path.normpath(path) if file_manager: - command_name = "explorer" - command_args = [f"/select,{normpath}"] + command_name = "explorer" + command_args = '/select,"' + normpath + '"' + # If the args are passed in a list, this will error when the path has spaces, even while surrounded in doule quotes. IDK why + subprocess.Popen(command_name + command_args, shell=True, close_fds=True, creationflags=subprocess.CREATE_NEW_PROCESS_GROUP | subprocess.CREATE_BREAKAWAY_FROM_JOB) else: command_name = "start" # first parameter is for title, NOT filepath command_args = ["", normpath] - subprocess.Popen([command_name] + command_args, shell=True, close_fds=True, creationflags=subprocess.CREATE_NEW_PROCESS_GROUP | subprocess.CREATE_BREAKAWAY_FROM_JOB) + subprocess.Popen([command_name] + command_args, shell=True, close_fds=True, creationflags=subprocess.CREATE_NEW_PROCESS_GROUP | subprocess.CREATE_BREAKAWAY_FROM_JOB) else: if sys.platform == "darwin": command_name = "open" From cd719c6d01cd83489af0cfeab9310ff3f596806b Mon Sep 17 00:00:00 2001 From: Sylvia Krech <40416079+Sylvia-Krech@users.noreply.github.com> Date: Thu, 2 May 2024 11:54:10 -0500 Subject: [PATCH 2/2] minor comment fix --- tagstudio/src/qt/helpers/file_opener.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tagstudio/src/qt/helpers/file_opener.py b/tagstudio/src/qt/helpers/file_opener.py index 65ab54a3..313db09f 100644 --- a/tagstudio/src/qt/helpers/file_opener.py +++ b/tagstudio/src/qt/helpers/file_opener.py @@ -37,7 +37,7 @@ def open_file(path: str, file_manager: bool = False): if file_manager: command_name = "explorer" command_args = '/select,"' + normpath + '"' - # If the args are passed in a list, this will error when the path has spaces, even while surrounded in doule quotes. IDK why + # For some reason, if the args are passed in a list, this will error when the path has spaces, even while surrounded in double quotes subprocess.Popen(command_name + command_args, shell=True, close_fds=True, creationflags=subprocess.CREATE_NEW_PROCESS_GROUP | subprocess.CREATE_BREAKAWAY_FROM_JOB) else: command_name = "start"