mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
Fix bug where -s could reset settings to defaults, closes #2389
This commit is contained in:
parent
f6bd2bf8b0
commit
bf953628bb
4 changed files with 70 additions and 1 deletions
|
|
@ -25,6 +25,7 @@ from .utils import (
|
|||
LoadExtension,
|
||||
StartupError,
|
||||
check_connection,
|
||||
deep_dict_update,
|
||||
find_spatialite,
|
||||
parse_metadata,
|
||||
ConnectionProblem,
|
||||
|
|
@ -552,7 +553,9 @@ def serve(
|
|||
# Merge in settings from -s/--setting
|
||||
if settings:
|
||||
settings_updates = pairs_to_nested_config(settings)
|
||||
config_data.update(settings_updates)
|
||||
# Merge recursively, to avoid over-writing nested values
|
||||
# https://github.com/simonw/datasette/issues/2389
|
||||
deep_dict_update(config_data, settings_updates)
|
||||
|
||||
kwargs = dict(
|
||||
immutables=immutable,
|
||||
|
|
|
|||
|
|
@ -1451,3 +1451,12 @@ async def calculate_etag(filepath, chunk_size=4096):
|
|||
_etag_cache[filepath] = etag
|
||||
|
||||
return etag
|
||||
|
||||
|
||||
def deep_dict_update(dict1, dict2):
|
||||
for key, value in dict2.items():
|
||||
if isinstance(value, dict):
|
||||
dict1[key] = deep_dict_update(dict1.get(key, type(value)()), value)
|
||||
else:
|
||||
dict1[key] = value
|
||||
return dict1
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue