From 170e3113e142cd13db4ca779f8a6aab2629598f6 Mon Sep 17 00:00:00 2001 From: Jo Vandeginste Date: Wed, 31 Jul 2019 15:08:24 +0200 Subject: [PATCH] When path starts with slash, consider it absolute When SQLite path starts with a `/`, we consider this to be an absolute path. Eg.: ```json { "data_provider":{ "name":"/var/lib/sftpgo/sftpgo.db" } } ``` --- dataprovider/sqlite.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/dataprovider/sqlite.go b/dataprovider/sqlite.go index e14f7df6..b9f84dbc 100644 --- a/dataprovider/sqlite.go +++ b/dataprovider/sqlite.go @@ -18,7 +18,10 @@ func initializeSQLiteProvider(basePath string) error { var err error var connectionString string if len(config.ConnectionString) == 0 { - dbPath := filepath.Join(basePath, config.Name) + dbPath := config.Name + if !filepath.IsAbs(dbPath) { + dbPath = filepath.Join(basePath, dbPath) + } fi, err := os.Stat(dbPath) if err != nil { logger.Warn(logSender, "sqlite database file does not exists, please be sure to create and initialize"+