From 9c2252692f29c2a19423c383a529191ef0f27bae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Brunner?= Date: Mon, 26 Jun 2023 13:59:02 +0200 Subject: [PATCH] Add the time of the last change --- scan_to_paperless/status.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/scan_to_paperless/status.py b/scan_to_paperless/status.py index d0c7292f..e71902db 100644 --- a/scan_to_paperless/status.py +++ b/scan_to_paperless/status.py @@ -34,6 +34,7 @@ def __init__(self, no_write: bool = False) -> None: self._file = os.path.join(os.environ.get("SCAN_SOURCE_FOLDER", "/source"), "status.html") self._status: Dict[str, _Folder] = {} self._global_status = "Starting..." + self._global_status_update = datetime.datetime.utcnow().replace(microsecond=0) self._start_time = datetime.datetime.utcnow().replace(microsecond=0) self._last_scan = datetime.datetime.utcnow() self.scan() @@ -41,7 +42,12 @@ def __init__(self, no_write: bool = False) -> None: def set_global_status(self, status: str) -> None: """Set the global status.""" + if self._global_status == status: + return + self._global_status = status + self._global_status_update = datetime.datetime.utcnow().replace(microsecond=0) + self.write() def set_status(self, name: str, status: str, details: str = "") -> None: @@ -160,7 +166,9 @@ def write(self) -> None:

Scan to Paperless status

-

{self._global_status}

+

{self._global_status} since

Started at: