|
5 | 5 |
|
6 | 6 | from .. import exceptions
|
7 | 7 | from ..utils import cached_property
|
8 |
| -from .utils import handle_collection_not_found |
| 8 | +from .utils import handle_collection_not_found, handle_collection_was_removed |
9 | 9 | from .utils import handle_storage_init_error
|
10 | 10 | from .utils import load_status
|
11 | 11 | from .utils import save_status
|
@@ -80,6 +80,39 @@ def collections_for_pair(status_path, pair, from_cache=True,
|
80 | 80 | get_b_discovered=b_discovered.get_self,
|
81 | 81 | _handle_collection_not_found=handle_collection_not_found
|
82 | 82 | ))
|
| 83 | + if "from b" in pair.collections: |
| 84 | + only_in_a = set(a_discovered.get_self().keys()) - set(b_discovered.get_self().keys()) |
| 85 | + if only_in_a and 'delete' in pair.config_a.get('implicit', []): |
| 86 | + for a in only_in_a: |
| 87 | + try: |
| 88 | + handle_collection_was_removed(pair.config_a, a) |
| 89 | + try: |
| 90 | + save_status(status_path, pair.name, a, data_type='metadata', data=None) |
| 91 | + except OSError: # the .metadata file has not existed |
| 92 | + pass |
| 93 | + try: |
| 94 | + save_status(status_path, pair.name, a, data_type='items', data=None) |
| 95 | + except OSError: # the .items file has not existed |
| 96 | + pass |
| 97 | + except NotImplementedError as e: |
| 98 | + cli_logger.error(e) |
| 99 | + |
| 100 | + if "from a" in pair.collections: |
| 101 | + only_in_b = set(b_discovered.get_self().keys()) - set(a_discovered.get_self().keys()) |
| 102 | + if only_in_b and 'delete' in pair.config_b.get('implicit', []): |
| 103 | + for b in only_in_b: |
| 104 | + try: |
| 105 | + handle_collection_was_removed(pair.config_b, b) |
| 106 | + try: |
| 107 | + save_status(status_path, pair.name, b, data_type='metadata', data=None) |
| 108 | + except OSError: # the .metadata file has not existed |
| 109 | + pass |
| 110 | + try: |
| 111 | + save_status(status_path, pair.name, b, data_type='items', data=None) |
| 112 | + except OSError: # the .items file has not existed |
| 113 | + pass |
| 114 | + except NotImplementedError as e: |
| 115 | + cli_logger.error(e) |
83 | 116 |
|
84 | 117 | _sanity_check_collections(rv)
|
85 | 118 |
|
|
0 commit comments