From 0462a561c1e3181cffb89401fcecdfbd25529ceb Mon Sep 17 00:00:00 2001 From: Marian Beermann Date: Mon, 12 Jun 2017 09:16:05 +0200 Subject: [PATCH] item: explicate csize isn't memorizable --- src/borg/item.pyx | 1 + src/borg/testsuite/item.py | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/src/borg/item.pyx b/src/borg/item.pyx index 5ca93404f..91fe57ee1 100644 --- a/src/borg/item.pyx +++ b/src/borg/item.pyx @@ -189,6 +189,7 @@ class Item(PropDict): If memorize is True, the computed size value will be stored into the item. """ attr = 'csize' if compressed else 'size' + assert not (compressed and memorize), 'Item does not have a csize field.' try: if from_chunks: raise AttributeError diff --git a/src/borg/testsuite/item.py b/src/borg/testsuite/item.py index 785a962ca..f9d72f87c 100644 --- a/src/borg/testsuite/item.py +++ b/src/borg/testsuite/item.py @@ -154,6 +154,11 @@ def test_item_file_size(): ChunkListEntry(csize=1, size=2000, id=None), ]) assert item.get_size() == 3000 + with pytest.raises(AssertionError): + item.get_size(compressed=True, memorize=True) + assert item.get_size(compressed=True) == 2 + item.get_size(memorize=True) + assert item.size == 3000 def test_item_file_size_no_chunks():