diff --git a/CHANGELOG.md b/CHANGELOG.md index 2ccd801ef82847389f3a3b5920a58d72b000606b..fc7d6ac33039cdc2d4728c354ecc24fa23092912 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [Unreleased] +### Fixed +- Fixed case when updates were installed automatically, even though manual + confirmation was required. + ## [1.5.2] - 2022-03-17 ### Fixed - crash when approvals are enabled without window being configured diff --git a/svupdater/approvals.py b/svupdater/approvals.py index f2b8c86fc4b9ccb6dd82b0c0bc8f28811e2203e3..9b14b2de134072e699876a95bfcc3e3885e94292 100644 --- a/svupdater/approvals.py +++ b/svupdater/approvals.py @@ -139,16 +139,23 @@ def _approved(now: typing.Optional[datetime.datetime] = None): now = now or datetime.datetime.now() auto_grant_time = autorun.auto_approve_time() auto_grant_window = autorun.auto_approve_window() + approval_in_window = auto_grant_window and auto_grant_window.in_window(now) + with const.APPROVALS_STAT_FILE.open("r") as file: - cols = file.readline().split(" ") - if cols[1].strip() == "granted" or ( - (auto_grant_window is None or auto_grant_window.in_window(now)) - and ( - not auto_grant_time or auto_grant_time and (int(cols[2]) < (now.timestamp() - (auto_grant_time * 3600))) - ) - ): - return cols[0] - return None + cols = file.readline().split() + + delayed_time_passed = auto_grant_time and (int(cols[2]) < (now.timestamp() - (auto_grant_time * 3600))) + approval_hash = cols[0] + if cols[1].strip() == "granted": + return approval_hash + + if delayed_time_passed and auto_grant_window is None: + return approval_hash + + if approval_in_window and (auto_grant_time is None or delayed_time_passed): + return approval_hash + + return None def next_approve(now: typing.Optional[datetime.datetime] = None) -> typing.Optional[datetime.datetime]: