Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ensure immutable databses when starting in configuration directory mode with #1229

Merged
merged 4 commits into from
Mar 29, 2021

Conversation

camallen
Copy link
Contributor

fixes #1224

This PR ensures all databases found in a configuration directory that match the files in inspect-data.json will be set to immutable as outlined in https://docs.datasette.io/en/latest/settings.html#configuration-directory-mode

specifically on building the datasette instance it checks:

  • if immutables is an empty tuple - as passed by the cli code
  • if immutables is the default function value None - when it's not explicitly set

And correctly builds the immutable database list from the inspect-data[file] keys.

Note for this to work the inspect-data.json file must contain file paths which are relative to the configuration directory otherwise the file paths won't match and the dbs won't be set to immutable.

I couldn't find an easy way to test this due to the way make_app_client works, happy to take directions on adding a test for this.

I've updated the relevant docs as well, i.e. use the inspect cli cmd from the config directory path to create the relevant file

cd $config_dir
datasette inspect *.db --inspect-file=inspect-data.json

https://docs.datasette.io/en/latest/performance.html#using-datasette-inspect

@codecov
Copy link

codecov bot commented Feb 17, 2021

Codecov Report

Merging #1229 (a095248) into main (8e18c79) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #1229   +/-   ##
=======================================
  Coverage   91.51%   91.51%           
=======================================
  Files          34       34           
  Lines        4255     4255           
=======================================
  Hits         3894     3894           
  Misses        361      361           
Impacted Files Coverage Δ
datasette/app.py 95.85% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8e18c79...a095248. Read the comment docs.

@camallen
Copy link
Contributor Author

I believe this pr and #1031 are related and fix the same issue.

@simonw
Copy link
Owner

simonw commented Mar 29, 2021

Thanks for figuring this out!

@simonw simonw closed this Mar 29, 2021
@simonw simonw reopened this Mar 29, 2021
@simonw simonw merged commit f92d823 into simonw:main Mar 29, 2021
simonw added a commit that referenced this pull request Mar 29, 2021
@camallen camallen deleted the fix-immutable-tuples branch April 22, 2022 13:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

can't start immutable databases from configuration dir mode
2 participants