From f051f4acd69eb50b49de7751aff5c52dd880fca4 Mon Sep 17 00:00:00 2001 From: Mario Fetka Date: Thu, 23 Jul 2026 15:16:46 +0200 Subject: [PATCH] Preserve collection flags during store restore --- src/apps/storetool/bongo/storetool/BackupCommands.py | 1 + src/apps/storetool/tests/test_python3_runtime.py | 12 ++++++++++++ src/libs/python/bongo/store/StoreClient.py | 4 +++- 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/apps/storetool/bongo/storetool/BackupCommands.py b/src/apps/storetool/bongo/storetool/BackupCommands.py index effa84c..637608d 100644 --- a/src/apps/storetool/bongo/storetool/BackupCommands.py +++ b/src/apps/storetool/bongo/storetool/BackupCommands.py @@ -245,6 +245,7 @@ class StoreRestoreCommand(Command): metadata = member.pax_headers store.Create( name, guid=metadata.get("BONGO.uid", ""), + flags=int(metadata["BONGO.flags"]), existingOk=True) self.RestoreProps(store, name, metadata) diff --git a/src/apps/storetool/tests/test_python3_runtime.py b/src/apps/storetool/tests/test_python3_runtime.py index f532d8f..a77dd2b 100644 --- a/src/apps/storetool/tests/test_python3_runtime.py +++ b/src/apps/storetool/tests/test_python3_runtime.py @@ -79,6 +79,18 @@ class Python3RuntimeTests(unittest.TestCase): "alice", "alice-store", host="store.example.test", port=1689, authPassword="secret") + def test_create_can_restore_collection_flags(self): + client = StoreClient.__new__(StoreClient) + client.stream = _Stream([_Response(1000)]) + + client.Create( + "/mail/sent", guid="0000000000000010", flags=128, + existingOk=True) + + self.assertEqual( + client.stream.lines, + ["CREATE /mail/sent 0000000000000010 128"]) + def test_calendar_import_splits_events_and_normalizes_collection_names(self): import vobject diff --git a/src/libs/python/bongo/store/StoreClient.py b/src/libs/python/bongo/store/StoreClient.py index 1dd6e7c..39c62b2 100644 --- a/src/libs/python/bongo/store/StoreClient.py +++ b/src/libs/python/bongo/store/StoreClient.py @@ -428,8 +428,10 @@ class StoreClient: self.stream.log.debug("READ: 1000 ****************") return r.message - def Create(self, path, guid="", existingOk=False): + def Create(self, path, guid="", flags=None, existingOk=False): command = "CREATE %s %s" % (path, guid) + if flags is not None: + command = command + " %d" % int(flags) self.stream.Write(command) r = self.stream.GetResponse()