mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-12-04 05:39:57 -05:00
Saving zims.yaml keeps the entries of Zims the database does not have yet (#935)
A rebuilt database imports zims.yaml before the refresh has modeled a single Zim. That import has no database version to compare with, so it saves the config afterward, and the save wrote only the Zims in the database: none. The file's choices were erased and every Zim was then modeled with the default. The dump now starts from the file's entries and overlays the database's, so a choice survives until its Zim is modeled again, and a Zim in the database still decides its own line. Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
parent
c0452e29e6
commit
5be899bf1f
2 changed files with 34 additions and 2 deletions
|
|
@ -843,11 +843,14 @@ class ZimsConfig(ConfigFile):
|
|||
raise
|
||||
|
||||
def dump_config(self, file: pathlib.Path = None, send_events=False, overwrite=False):
|
||||
"""Save every Zim's settings. Of several versions of one Zim, the newest decides."""
|
||||
"""Save every Zim's settings. Of several versions of one Zim, the newest decides.
|
||||
|
||||
The file's entries for Zims the database does not have are kept: a rebuilt database imports this config
|
||||
(and saves it) before the refresh has modeled a single Zim, and the choices must survive until then."""
|
||||
with get_db_session() as session:
|
||||
version = self.db_version_for_dump(session)
|
||||
auto_search = self.auto_search
|
||||
# Sorted by path, so the newest version of a Zim (its date sorts last) wins.
|
||||
auto_search = dict()
|
||||
for zim in session.query(Zim).order_by(Zim.path):
|
||||
auto_search[zim_config_name(zim.path)] = bool(zim.auto_search)
|
||||
self._config['auto_search'] = dict(sorted(auto_search.items()))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue