diff --git a/tests/test_daemon.py b/tests/test_daemon.py index 8a002cf..4570410 100644 --- a/tests/test_daemon.py +++ b/tests/test_daemon.py @@ -18,7 +18,6 @@ SCRIPT = Path(os.environ.get("XIDLE_INHIBIT") or Path(__file__).resolve().parent BUS_NAME = "org.freedesktop.ScreenSaver" OBJECT_PATH = "/org/freedesktop/ScreenSaver" STATE_FILE = "xidle-inhibit.json" -OLD_STATE_FILE = "xautolock-inhibit.json" TIMEOUT = 5.0 DELAY = ["--release-delay", "1"] SETTLE = 1.5 # longer than DELAY, to check that nothing happens @@ -387,21 +386,6 @@ def test_old_crash_is_not_restored(sb: Sandbox) -> None: assert "over the 30s window" in sb.log() -def test_old_state_file_is_read_once_and_deleted(sb: Sandbox) -> None: - a = sb.client() - old = sb.runtime / OLD_STATE_FILE - old.write_text(json.dumps({ - "bus_id": a.conn.get_guid(), "last_cookie": 7, "stopped_at": time.time(), - "cookies": [[7, a.name, "test-app", "Playing video"]], - })) - sb.start() - assert sb.calls() == [DISABLE] - assert "(xautolock-inhibit)" in sb.log() - assert not old.exists() - assert json.loads(sb.state_file.read_text())["cookies"] == [[7, a.name, "test-app", "Playing video"]] - assert a.inhibit() == 8 - - def test_unreadable_state_file_is_ignored(sb: Sandbox) -> None: sb.state_file.write_text("{not json") sb.start() diff --git a/xidle-inhibit b/xidle-inhibit index 7a9b605..26cd2ce 100755 --- a/xidle-inhibit +++ b/xidle-inhibit @@ -31,7 +31,6 @@ OBJECT_PATHS = ("/org/freedesktop/ScreenSaver", "/ScreenSaver") # Vivaldi uses EXIT_NAME_TAKEN = 2 ACTIVITY_QUIET = 300 # seconds without SimulateUserActivity that end a logged burst STATE_FILE = "xidle-inhibit.json" # in $XDG_RUNTIME_DIR -OLD_STATE_FILE = "xautolock-inhibit.json" # before the rename (0.2); read once when upgrading STATE_HEARTBEAT = 10 # seconds between state file touches while inhibits are held CONFIG_FILE = "xidle-inhibit/config" # in $XDG_CONFIG_HOME BACKENDS = ("xautolock", "xss-lock") @@ -228,14 +227,6 @@ class Inhibitor: self.restore() self.state_ready = True self.save() - if self.state_path: - old = os.path.join(os.path.dirname(self.state_path), OLD_STATE_FILE) - try: - os.remove(old) - except FileNotFoundError: - pass - except OSError as e: - log(f"Cannot remove old state file {old}: {e}") if self.active_count(): self.block() elif self.xautolock: @@ -248,9 +239,6 @@ class Inhibitor: return assert self.conn is not None path = self.state_path - old = os.path.join(os.path.dirname(path), OLD_STATE_FILE) - if not os.path.exists(path) and os.path.exists(old): - path = old try: with open(path) as f: state = json.load(f) @@ -263,8 +251,6 @@ class Inhibitor: except (OSError, ValueError, KeyError, TypeError) as e: log(f"Ignoring unreadable state file {path}: {e}") return - if path == old: - log(f"Reading inhibits from {old} (xautolock-inhibit)") if bus_id != self.conn.get_guid(): # Unique names like :1.42 are reused by a new bus, so they would mean other clients. if saved: