diff options
author | Kegsay <kegan@matrix.org> | 2020-06-04 11:18:08 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-04 11:18:08 +0100 |
commit | e7d1ac84c32a10f8deb7bcfc94531386312179c7 (patch) | |
tree | cfb8176ebcd9cd1087aa1c34f6f362dd2851dcdc /appservice | |
parent | d4f9a4bb97c0c66963d7fd9c1395614a2198112e (diff) |
Add ParseFileURI and use it when dealing with file URIs (#1088)
* Add ParseFileURI and use it when dealing with file URIs
Fixes #1059
* Missing file
* Linting
Diffstat (limited to 'appservice')
-rw-r--r-- | appservice/storage/sqlite3/storage.go | 6 | ||||
-rw-r--r-- | appservice/storage/storage_wasm.go | 2 |
2 files changed, 6 insertions, 2 deletions
diff --git a/appservice/storage/sqlite3/storage.go b/appservice/storage/sqlite3/storage.go index 275c6652..2238b3ff 100644 --- a/appservice/storage/sqlite3/storage.go +++ b/appservice/storage/sqlite3/storage.go @@ -37,7 +37,11 @@ type Database struct { func NewDatabase(dataSourceName string) (*Database, error) { var result Database var err error - if result.db, err = sqlutil.Open(internal.SQLiteDriverName(), dataSourceName, nil); err != nil { + cs, err := sqlutil.ParseFileURI(dataSourceName) + if err != nil { + return nil, err + } + if result.db, err = sqlutil.Open(internal.SQLiteDriverName(), cs, nil); err != nil { return nil, err } if err = result.prepare(); err != nil { diff --git a/appservice/storage/storage_wasm.go b/appservice/storage/storage_wasm.go index de1acf92..a6144b43 100644 --- a/appservice/storage/storage_wasm.go +++ b/appservice/storage/storage_wasm.go @@ -34,7 +34,7 @@ func NewDatabase( case "postgres": return nil, fmt.Errorf("Cannot use postgres implementation") case "file": - return sqlite3.NewDatabase(uri.Path) + return sqlite3.NewDatabase(dataSourceName) default: return nil, fmt.Errorf("Cannot use postgres implementation") } |