Skip to content

Commit 97e9757

Browse files
committed
Added similar year-finding logic to the 'process_gain' API endpoint
1 parent 26771bf commit 97e9757

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/murfey/server/api/__init__.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1502,6 +1502,26 @@ async def process_gain(
15021502
/ secure_filename(visit_name)
15031503
/ machine_config.gain_directory_name
15041504
)
1505+
1506+
# Check under previous year if the folder doesn't exist
1507+
if not filepath.exists():
1508+
filepath_prev = filepath
1509+
filepath = (
1510+
Path(machine_config.rsync_basepath)
1511+
/ (machine_config.rsync_module or "data")
1512+
/ str(datetime.datetime.now().year - 1)
1513+
/ secure_filename(visit_name)
1514+
/ machine_config.gain_directory_name
1515+
)
1516+
# If it's not in the previous year, it's a genuine error
1517+
if not filepath.exists():
1518+
log_message = (
1519+
"Unable to find gain reference directory under "
1520+
f"{str(filepath_prev)!r} or {str(filepath)}"
1521+
)
1522+
log.error(log_message)
1523+
raise FileNotFoundError(log_message)
1524+
15051525
if gain_reference_params.eer:
15061526
new_gain_ref, new_gain_ref_superres = await prepare_eer_gain(
15071527
filepath / safe_path_name,

0 commit comments

Comments
 (0)