Skip to content

Commit 1951fc5

Browse files
yashhzdamilcarlucas
authored andcommitted
fix(filesystem): clarify no-tcal fallback comment and info_msg
Address review feedback on PR #1553: the previous "Starting with the first non-tcal file." log line was technically inaccurate when the fallback path fired, because we then start from the last file rather than position [2]. Split the two cases into distinct branches with distinct log messages so the user sees exactly which case applied. No behavioural change. Tests unchanged and still pass. Signed-off-by: Yash Goel <yashvardhan664@gmail.com>
1 parent 06461f0 commit 1951fc5

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

ardupilot_methodic_configurator/backend_filesystem.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -773,15 +773,19 @@ def get_start_file(self, explicit_index: int, tcal_available: bool) -> str:
773773
)
774774
return files[start_file_index]
775775

776+
# In the no-tcal branch the historical behaviour is files[2], i.e. skip
777+
# the first two files (typically 00_default.param + 01_tcal.param). Fall
778+
# back to the last available file when fewer than 3 files are present
779+
# so we never crash on a small or non-standard file set.
776780
if tcal_available:
777781
start_file = files[0]
778782
info_msg = _("Starting with the first file.")
779-
else:
780-
# files[2] skips 00_default.param + 01_tcal.param when tcal is not
781-
# available; fall back to the last file if fewer than 3 are present
782-
# so we never crash on a small or non-standard file set.
783-
start_file = files[2] if len(files) >= 3 else files[-1]
783+
elif len(files) >= 3:
784+
start_file = files[2]
784785
info_msg = _("Starting with the first non-tcal file.")
786+
else:
787+
start_file = files[-1]
788+
info_msg = _("Fewer than three files available; starting with the last file.")
785789

786790
last_uploaded_filename = self.__read_last_uploaded_filename()
787791
if last_uploaded_filename:

0 commit comments

Comments
 (0)