feat: make database location configurable

This commit is contained in:
Senghan Bright
2021-08-04 10:52:02 +02:00
parent 8b6f4b8981
commit 65a7d89eb8
3 changed files with 12 additions and 11 deletions

View File

@@ -85,10 +85,11 @@ local function validate_db(safe_mode)
end
end
local function init(config_ignore_patterns, safe_mode, auto_validate)
-- TODO: make init params a keyed table
local function init(db_root, config_ignore_patterns, safe_mode, auto_validate)
if sql_wrapper then return end
sql_wrapper = sqlwrap:new()
local first_run = sql_wrapper:bootstrap()
local first_run = sql_wrapper:bootstrap(db_root)
ignore_patterns = config_ignore_patterns or default_ignore_patterns
if auto_validate then

View File

@@ -34,14 +34,14 @@ function M:new()
return o
end
function M:bootstrap(opts)
function M:bootstrap(db_root)
if self.db then return end
opts = opts or {}
self.max_entries = opts.max_entries or 2000
-- opts = opts or {}
-- self.max_entries = opts.max_entries or 2000
-- create the db if it doesn't exist
local db_root = opts.docs_root or vim.fn.stdpath('data')
db_root = db_root or vim.fn.stdpath('data')
local db_filename = db_root .. "/file_frecency.sqlite3"
self.db = sql:open(db_filename)
if not self.db then