From 3fd2efcd7b90eb3842826698912684d97df303c5 Mon Sep 17 00:00:00 2001 From: neo Date: Fri, 6 Dec 2024 11:58:57 +0100 Subject: [PATCH] extra server on stten1/4/14 tbt --- src/components/archive_synchronizer.py | 28 ++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/src/components/archive_synchronizer.py b/src/components/archive_synchronizer.py index 92dd4fa..8a10742 100644 --- a/src/components/archive_synchronizer.py +++ b/src/components/archive_synchronizer.py @@ -58,16 +58,36 @@ class ArchiveSynchronizer(Component): if self.main_window is None: self.main_window = get_main_window() - - for record in list(Archive.select().where((Archive.archived != True) | (Archive.uploaded != True))): # using "is not True" breaks the query.. # list() forces the complete execution of the query unlocking the db unlike __enter__() + if self.name != "remote_archiver_extra": + # MAIN SERVER + bit_pos = 0 + unsaved_records = Archive.select().where((Archive.archived == 0) | + (Archive.archived == 2) | + (Archive.uploaded == 0)) + else: + # EXTRA SERVER (VERO PROJECT SPA) + bit_pos = 1 + unsaved_records = Archive.select().where((Archive.archived == 0) | + (Archive.archived == 1)) + for record in unsaved_records: if not self.simulate: if record.archived is not True: - record.archived = self.remote_archive(record) is True + s = time.time() + save_ok = self.remote_archive(record) is True + e = time.time() + else: + save_ok=True if record.uploaded is not True: record.uploaded = self.remote_store(record) is True else: self.log.info("simulated archive synchronizer cycle") - #record.save() + save_ok=True + + if save_ok: + record.archived |= (1 << bit_pos) + self.log(f"({self.name}) id {record.id}:", "archived remotely", f"{(e - s):.3f}s") + else: + self.log(f"({self.name}) id {record.id}:", "failed to archive remotely", f"{(e - s):.3f}s") self.main_window.run_request.emit(record.save, [], {}) if self.hold_time > 0: