Skip to content

Commit 022450c

Browse files
committed
basic backup added
added the backup time to config so that users can decide for how long do they want to keep the data Next: write tests for the new backup
1 parent 2876e50 commit 022450c

File tree

3 files changed

+3
-4
lines changed

3 files changed

+3
-4
lines changed

dls_barcode/config/barcode_config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ def __init__(self, file, file_manager):
4444

4545
self.store_directory = add(DirectoryConfigItem, "Store Directory", default=default_store)
4646
self.store_capacity = add(IntConfigItem, "Results History Size", default=50)
47+
self.backup_time = add(IntConfigItem, "Backup in Weeks", default=3)
4748

4849
self.console_frame = add(BoolConfigItem, "Print Frame Summary", default=False)
4950
self.slot_images = add(BoolConfigItem, "Save Debug Images", default=False)

dls_barcode/config/barcode_config_dialog.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ def _init_ui(self):
5555

5656
self.start_group("Store")
5757
self._add_control(StoreDirectoryConfigControl(cfg.store_directory))
58+
add(cfg.backup_time)
5859
add(cfg.store_capacity)
5960

6061
self.start_group("Debug")

dls_barcode/data_store/backup.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ class Backup:
99
Backup class maintains the short time backaup of records which is kept in the same folder as the store files.
1010
"""
1111

12-
MAX_BACKUP_TIME = 6 # maximum backup time in weeks
13-
1412
def __init__(self, directory, backup_time):
1513
self.comms = CommsManager(directory, "backup")
1614
self.backup_time = backup_time
@@ -31,7 +29,6 @@ def _is_old(self, record):
3129
tm = time.time()
3230
record_time = record.timestamp
3331
delta = tm - record_time
34-
backup_time = min(self.backup_time, self.MAX_BACKUP_TIME)
35-
weeks = backup_time * 604800 # weeks in seconds
32+
weeks = self.backup_time * 604800 # weeks in seconds
3633
return delta > weeks
3734

0 commit comments

Comments
 (0)