From 62afcdaaf6853b062f536910054df520326fa389 Mon Sep 17 00:00:00 2001 From: Florian Agbuya Date: Tue, 20 Aug 2024 16:39:24 +0000 Subject: [PATCH] gui/state: implement backup state file for last successful load (#2538) --- RELEASE_NOTES.rst | 1 + artiq/gui/state.py | 3 +++ 2 files changed, 4 insertions(+) diff --git a/RELEASE_NOTES.rst b/RELEASE_NOTES.rst index bb4a117fa..aa12c7816 100644 --- a/RELEASE_NOTES.rst +++ b/RELEASE_NOTES.rst @@ -6,6 +6,7 @@ Release notes ARTIQ-9 (Unreleased) -------------------- +* GUI state files are now automatically backed up upon successful loading. * Zotino monitoring in the dashboard now displays the values in volts. * afws_client now uses the "happy eyeballs" algorithm (RFC 6555) for a faster and more reliable connection to the server. diff --git a/artiq/gui/state.py b/artiq/gui/state.py index 3a3f21be8..a5f53c45e 100644 --- a/artiq/gui/state.py +++ b/artiq/gui/state.py @@ -1,6 +1,7 @@ import asyncio from collections import OrderedDict import logging +import shutil from sipyco.asyncio_tools import TaskObject from sipyco import pyon @@ -45,6 +46,8 @@ class StateManager(TaskObject): logger.info("State database '%s' not found, using defaults", self.filename) return + else: + shutil.copy2(self.filename, self.filename + ".backup") # The state of one object may depend on the state of another, # e.g. the display state may create docks that are referenced in # the area state.