Преглед изворни кода

item: explicate csize isn't memorizable

Marian Beermann пре 8 година
родитељ
комит
0462a561c1
2 измењених фајлова са 6 додато и 0 уклоњено
  1. 1 0
      src/borg/item.pyx
  2. 5 0
      src/borg/testsuite/item.py

+ 1 - 0
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

+ 5 - 0
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():