Skip to content

Commit 36efb6f

Browse files
committed
Fixed logic when reading rsync base path from machine config
1 parent feade10 commit 36efb6f

File tree

1 file changed

+7
-15
lines changed

1 file changed

+7
-15
lines changed

src/murfey/server/api/clem.py

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -81,23 +81,15 @@ def validate_and_sanitise(
8181
machine_config = get_machine_config(instrument_name=instrument_name)[
8282
instrument_name
8383
]
84-
rsync_basepath = machine_config.rsync_basepath
85-
try:
86-
base_path = list(rsync_basepath.parents)[-2].as_posix()
87-
except IndexError:
88-
# Print to troubleshoot
89-
logger.warning(f"Base path {rsync_basepath!r} is too short")
90-
base_path = rsync_basepath.as_posix()
91-
except Exception:
92-
raise Exception("Unexpected exception occurred when loading the file base path")
84+
base_path = machine_config.rsync_basepath.as_posix()
9385

9486
# Check that full file path doesn't contain unallowed characters
95-
# Currently allows only:
96-
# - words (alphanumerics and "_"; \w),
97-
# - spaces (\s),
98-
# - periods,
99-
# - dashes,
100-
# - forward slashes ("/")
87+
# Currently allows only:
88+
# - words (alphanumerics and "_"; \w),
89+
# - spaces (\s),
90+
# - periods,
91+
# - dashes,
92+
# - forward slashes ("/")
10193
if bool(re.fullmatch(r"^[\w\s\.\-/]+$", str(full_path))) is False:
10294
raise ValueError(f"Unallowed characters present in {file}")
10395

0 commit comments

Comments
 (0)