Repository: borgbackup/borgstore

Issue:
Store.list with delete=True vs. =False
Currently, giving True will list normal AND soft-deleted items. As it removes the .del postfix, the caller could not even know what is what.

So:
- False will only list not-deleted objects
- True will only list soft-deleted objects


Discussion:

Patch:
diff --git a/README.rst b/README.rst
index 0378e10..4dd8498 100644
--- a/README.rst
+++ b/README.rst
@@ -42,8 +42,8 @@ soft deletion, so the caller doesn't have to care much for that and the Backend
 API can be much simpler:
 
 - create/destroy: initialize or remove the whole store.
-- list: flat list of the items in the given namespace, with or without soft
-  deleted items.
+- list: flat list of the items in the given namespace (by default only not
+  soft deleted items, optionally only soft deleted items).
 - store: write a new item into the store (giving its key/value pair)
 - load: read a value from the store (giving its key), partial loads giving
   offset and/or size are supported.
diff --git a/src/borgstore/__main__.py b/src/borgstore/__main__.py
index 7fa4432..9cb61af 100644
--- a/src/borgstore/__main__.py
+++ b/src/borgstore/__main__.py
@@ -56,7 +56,7 @@ def run_demo(storage_url):
         store.move(key2, delete=True)
 
         print(f"Listing data namespace contents: {list(store.list('data', deleted=False))}")
-        print(f"Listing data namespace contents, incl. deleted: {list(store.list('data', deleted=True))}")
+        print(f"Listing data namespace contents (only deleted): {list(store.list('data', deleted=True))}")
 
         print(f"Stats: {store.stats}")
 
diff --git a/src/borgstore/store.py b/src/borgstore/store.py
index cd0ad4e..9d3aa91 100644
--- a/src/borgstore/store.py
+++ b/src/borgstore/store.py
@@ -253,8 +253,8 @@ class Store:
         """
         List all names in the namespace <name>.
 
-        If deleted is True and soft deleted items are encountered, they are yielded
-        as if they were not deleted. Otherwise, they are ignored.
+        If deleted is False (default), only normal (not soft deleted) items are yielded.
+        If deleted is True, only soft deleted items are yielded.
 
         backend.list giving us sorted names implies store.list is also sorted, if all items are stored on same level.
         """
@@ -290,5 +290,5 @@ class Store:
                 is_deleted = info.name.endswith(DEL_SUFFIX)
                 if deleted and is_deleted:
                     yield info._replace(name=info.name.removesuffix(DEL_SUFFIX))
-                elif not is_deleted:
+                elif not deleted and not is_deleted:
                     yield info


Test patch:
diff --git a/tests/test_store.py b/tests/test_store.py
index 76cdcfb..355794c 100644
--- a/tests/test_store.py
+++ b/tests/test_store.py
@@ -209,11 +209,11 @@ def test_move_delete_undelete(posixfs_store_created):
         # delete
         store.move(nsk0, delete=True)  # soft delete
         assert list_store_names(store, ns, deleted=False) == [k1]
-        assert list_store_names(store, ns, deleted=True) == [k0, k1]
+        assert list_store_names(store, ns, deleted=True) == [k0]
         # undelete
         store.move(nsk0, undelete=True)  # undelete previously soft deleted item
         assert list_store_names(store, ns, deleted=False) == [k0, k1]
-        assert list_store_names(store, ns, deleted=True) == [k0, k1]
+        assert list_store_names(store, ns, deleted=True) == []
 
 
 def test_move_change_level(posixfs_store_created):