From fc30a0765b5d252ee70c0d896a494ac975c8b961 Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Sat, 23 Feb 2019 10:09:40 +0100 Subject: [PATCH 1/2] remove ARCHIVE_KEYS duplication also: get key set in sync, obviously we have "recreate_partial_chunks" in ArchiveItem still. --- src/borg/constants.py | 2 +- src/borg/item.pyx | 7 ++----- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/borg/constants.py b/src/borg/constants.py index ff8eabb8d..86c4d72ee 100644 --- a/src/borg/constants.py +++ b/src/borg/constants.py @@ -10,7 +10,7 @@ # this set must be kept complete, otherwise rebuild_manifest might malfunction: ARCHIVE_KEYS = frozenset(['version', 'name', 'items', 'cmdline', 'hostname', 'username', 'time', 'time_end', 'comment', 'chunker_params', - 'recreate_cmdline', 'recreate_source_id', 'recreate_args']) + 'recreate_cmdline', 'recreate_source_id', 'recreate_args', 'recreate_partial_chunks',]) # this is the set of keys that are always present in archives: REQUIRED_ARCHIVE_KEYS = frozenset(['version', 'name', 'items', 'cmdline', 'time', ]) diff --git a/src/borg/item.pyx b/src/borg/item.pyx index 754896114..aa078d868 100644 --- a/src/borg/item.pyx +++ b/src/borg/item.pyx @@ -1,7 +1,7 @@ import stat from collections import namedtuple -from .constants import ITEM_KEYS +from .constants import ITEM_KEYS, ARCHIVE_KEYS from .helpers import safe_encode, safe_decode from .helpers import bigint_to_int, int_to_bigint from .helpers import StableDict @@ -349,10 +349,7 @@ class ArchiveItem(PropDict): If a ArchiveItem shall be serialized, give as_dict() method output to msgpack packer. """ - VALID_KEYS = {'version', 'name', 'items', 'cmdline', 'hostname', 'username', 'time', 'time_end', - 'comment', 'chunker_params', - 'recreate_cmdline', 'recreate_source_id', 'recreate_args', 'recreate_partial_chunks', - } # str-typed keys + VALID_KEYS = ARCHIVE_KEYS # str-typed keys __slots__ = ("_dict", ) # avoid setting attributes not supported by properties From 58f177aa821c620b2c26cacb4b9a7f5cd6086381 Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Sat, 23 Feb 2019 10:49:24 +0100 Subject: [PATCH 2/2] add comment about unused recreate_* members in ArchiveItem --- src/borg/constants.py | 4 +++- src/borg/helpers/checks.py | 2 +- src/borg/item.pyx | 5 +++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/borg/constants.py b/src/borg/constants.py index 86c4d72ee..eecb344dd 100644 --- a/src/borg/constants.py +++ b/src/borg/constants.py @@ -10,7 +10,9 @@ # this set must be kept complete, otherwise rebuild_manifest might malfunction: ARCHIVE_KEYS = frozenset(['version', 'name', 'items', 'cmdline', 'hostname', 'username', 'time', 'time_end', 'comment', 'chunker_params', - 'recreate_cmdline', 'recreate_source_id', 'recreate_args', 'recreate_partial_chunks',]) + 'recreate_cmdline', + 'recreate_source_id', 'recreate_args', 'recreate_partial_chunks', # used in 1.1.0b1 .. b2 + ]) # this is the set of keys that are always present in archives: REQUIRED_ARCHIVE_KEYS = frozenset(['version', 'name', 'items', 'cmdline', 'time', ]) diff --git a/src/borg/helpers/checks.py b/src/borg/helpers/checks.py index 984f95f97..5e4cecffd 100644 --- a/src/borg/helpers/checks.py +++ b/src/borg/helpers/checks.py @@ -35,5 +35,5 @@ def check_extension_modules(): raise ExtensionModuleError if platform.API_VERSION != platform.OS_API_VERSION or platform.API_VERSION != '1.2_03': raise ExtensionModuleError - if item.API_VERSION != '1.1_04': + if item.API_VERSION != '1.1_05': raise ExtensionModuleError diff --git a/src/borg/item.pyx b/src/borg/item.pyx index aa078d868..ee67ee0d2 100644 --- a/src/borg/item.pyx +++ b/src/borg/item.pyx @@ -12,7 +12,7 @@ cdef extern from "_item.c": object _optr_to_object(object bytes) -API_VERSION = '1.1_04' +API_VERSION = '1.1_05' class PropDict: @@ -363,8 +363,9 @@ class ArchiveItem(PropDict): time_end = PropDict._make_property('time_end', str, 'surrogate-escaped str', encode=safe_encode, decode=safe_decode) comment = PropDict._make_property('comment', str, 'surrogate-escaped str', encode=safe_encode, decode=safe_decode) chunker_params = PropDict._make_property('chunker_params', tuple, 'chunker-params tuple', encode=tuple_encode, decode=tuple_decode) - recreate_source_id = PropDict._make_property('recreate_source_id', bytes) recreate_cmdline = PropDict._make_property('recreate_cmdline', list) # list of s-e-str + # recreate_source_id, recreate_args, recreate_partial_chunks were used in 1.1.0b1 .. b2 + recreate_source_id = PropDict._make_property('recreate_source_id', bytes) recreate_args = PropDict._make_property('recreate_args', list) # list of s-e-str recreate_partial_chunks = PropDict._make_property('recreate_partial_chunks', list) # list of tuples