Index: cloudsync/utils/watchdog.py =================================================================== diff -u -rf8e86cb57ba35fd2a6f6ec1b7989443bff221b0d -rff767085ef6d1eb776deb211583a907e872bdb5d --- cloudsync/utils/watchdog.py (.../watchdog.py) (revision f8e86cb57ba35fd2a6f6ec1b7989443bff221b0d) +++ cloudsync/utils/watchdog.py (.../watchdog.py) (revision ff767085ef6d1eb776deb211583a907e872bdb5d) @@ -30,8 +30,13 @@ from time import monotonic, sleep -# Default sentinel file path — cs.py monitors this to trigger process restart -SENTINEL_PATH = "/media/sd-card/cloudsync/cloudsync_restart_sentinel" +# Default sentinel file path — cs.py monitors this to trigger process restart. +# Placed in a dedicated sentinel/ subfolder under the SD card root so the +# inotify watch on /media/sd-card/cloudsync (non-recursive, set up by +# FileInputBus for UI->CS bus files) does not fire on sentinel writes. The +# subfolder is auto-created at Watchdog __init__ time; isolated from the +# log/ subfolder so log-retention sweeps cannot reach it. +SENTINEL_PATH = "/media/sd-card/cloudsync/sentinel/cloudsync_restart_sentinel" class Watchdog: @@ -55,6 +60,22 @@ self._stop_event = Event() self._thread = Thread(target=self._monitor, daemon=True) + # Ensure the sentinel directory exists at construction time. The + # dedicated subfolder is isolated from FileInputBus's non-recursive + # inotify watch on the channels root and from log-retention sweeps + # of the log/ subfolder; first-run install / upgrade from a build + # whose layout did not include this folder is handled here so the + # release artifact does not need to ship the empty directory. + sentinel_dir = os.path.dirname(self._sentinel_path) + if sentinel_dir: + try: + os.makedirs(sentinel_dir, exist_ok=True) + except OSError as exc: + self._logger.warning( + "Watchdog: could not pre-create sentinel directory %s: %s", + sentinel_dir, exc, + ) + # ------------------------------------------------------------------ # Public API # ------------------------------------------------------------------