From 14cc3f9fcfd683aa3fe35cc1aefc868d64c03153 Mon Sep 17 00:00:00 2001 From: Julian Stirling Date: Sun, 21 Sep 2025 16:50:04 +0100 Subject: [PATCH] Fix error trying to purge empty scans if current scan has no images Closes #563 --- src/openflexure_microscope_server/things/smart_scan.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/openflexure_microscope_server/things/smart_scan.py b/src/openflexure_microscope_server/things/smart_scan.py index 1b760e13..59ff87dc 100644 --- a/src/openflexure_microscope_server/things/smart_scan.py +++ b/src/openflexure_microscope_server/things/smart_scan.py @@ -179,6 +179,9 @@ class SmartScanThing(lt.Thing): # Ensure any PreviewStitcher created cannot be reused. self._preview_stitcher = None + # Remove any scan folders containing zero images. + self.purge_empty_scans(logger=logger) + @_scan_running def _check_background_and_csm_set(self) -> None: """Before starting a scan, check that background and camera-stage-mapping are set. @@ -386,9 +389,6 @@ class SmartScanThing(lt.Thing): self._return_to_starting_position() self._perform_final_stitch() - # Remove any scan folders containing zero images - self.purge_empty_scans(logger=self._scan_logger) - @_scan_running def _main_scan_loop(self) -> None: """Run the main loop of the scan.