|
9 | 9 | import aiohttp
|
10 | 10 | import aiostream
|
11 | 11 |
|
| 12 | +from . import cli_logger |
12 | 13 | from .. import exceptions
|
13 | 14 | from .utils import handle_collection_not_found
|
| 15 | +from .utils import handle_collection_was_removed |
14 | 16 | from .utils import handle_storage_init_error
|
15 | 17 | from .utils import load_status
|
16 | 18 | from .utils import save_status
|
@@ -106,6 +108,29 @@ async def collections_for_pair(
|
106 | 108 | _handle_collection_not_found=handle_collection_not_found,
|
107 | 109 | )
|
108 | 110 | )
|
| 111 | + if "from b" in (pair.collections or []): |
| 112 | + only_in_a = set((await a_discovered.get_self()).keys()) - set( |
| 113 | + (await b_discovered.get_self()).keys()) |
| 114 | + if only_in_a and "delete" in pair.config_a["implicit"]: |
| 115 | + for a in only_in_a: |
| 116 | + try: |
| 117 | + handle_collection_was_removed(pair.config_a, a) |
| 118 | + save_status(status_path, pair.name, a, data_type="metadata") |
| 119 | + save_status(status_path, pair.name, a, data_type="items") |
| 120 | + except NotImplementedError as e: |
| 121 | + cli_logger.error(e) |
| 122 | + |
| 123 | + if "from a" in (pair.collections or []): |
| 124 | + only_in_b = set((await b_discovered.get_self()).keys()) - set( |
| 125 | + (await a_discovered.get_self()).keys()) |
| 126 | + if only_in_b and "delete" in pair.config_b["implicit"]: |
| 127 | + for b in only_in_b: |
| 128 | + try: |
| 129 | + handle_collection_was_removed(pair.config_b, b) |
| 130 | + save_status(status_path, pair.name, b, data_type="metadata") |
| 131 | + save_status(status_path, pair.name, b, data_type="items") |
| 132 | + except NotImplementedError as e: |
| 133 | + cli_logger.error(e) |
109 | 134 |
|
110 | 135 | await _sanity_check_collections(rv, connector=connector)
|
111 | 136 |
|
|
0 commit comments