|
37 | 37 | # LibraryInfo fields that change between runs without a configuration change. |
38 | 38 | _VOLATILE_LIBRARY_INFO_FIELDS = frozenset({"last_updated", "needs_update"}) |
39 | 39 |
|
40 | | -# LibraryInfo tuple fields whose values are compared as unordered sets. |
| 40 | +# LibraryInfo tuple fields compared order-independently. Duplicate values are |
| 41 | +# significant: each web client URL produces its own 856 field, so a duplicate |
| 42 | +# URL changes the export and must register as a difference. |
41 | 43 | # TODO: The `filtered_audiences` and `filtered_genres` library settings are |
42 | 44 | # compared below, but changing them does not yet queue a MARC export reset. |
43 | | -_UNORDERED_LIBRARY_INFO_FIELDS = frozenset( |
| 45 | +_ORDER_INSENSITIVE_LIBRARY_INFO_FIELDS = frozenset( |
44 | 46 | {"web_client_urls", "filtered_audiences", "filtered_genres"} |
45 | 47 | ) |
46 | 48 |
|
@@ -128,12 +130,13 @@ def _export_settings_changed(snapshot: LibraryInfo, current: LibraryInfo) -> boo |
128 | 130 | """Whether a library's export-affecting settings differ between two LibraryInfo. |
129 | 131 |
|
130 | 132 | Ignores the fields that may change between runs without affecting the export |
131 | | - and compares the tuple fields as unordered sets of values. |
| 133 | + and compares the tuple fields order-independently, with duplicate values |
| 134 | + significant. |
132 | 135 | """ |
133 | 136 |
|
134 | 137 | def comparable(info: LibraryInfo) -> dict[str, Any]: |
135 | 138 | dumped = info.model_dump(exclude=set(_VOLATILE_LIBRARY_INFO_FIELDS)) |
136 | | - for field in _UNORDERED_LIBRARY_INFO_FIELDS: |
| 139 | + for field in _ORDER_INSENSITIVE_LIBRARY_INFO_FIELDS: |
137 | 140 | dumped[field] = sorted(dumped[field]) |
138 | 141 | return dumped |
139 | 142 |
|
|
0 commit comments