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 /mediaapi | |
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 'mediaapi')
-rw-r--r-- | mediaapi/storage/sqlite3/storage.go | 6 | ||||
-rw-r--r-- | mediaapi/storage/storage_wasm.go | 2 |
2 files changed, 6 insertions, 2 deletions
diff --git a/mediaapi/storage/sqlite3/storage.go b/mediaapi/storage/sqlite3/storage.go index 6da7132d..ea81f912 100644 --- a/mediaapi/storage/sqlite3/storage.go +++ b/mediaapi/storage/sqlite3/storage.go @@ -37,7 +37,11 @@ type Database struct { func Open(dataSourceName string) (*Database, error) { var d Database var err error - if d.db, err = sqlutil.Open(internal.SQLiteDriverName(), dataSourceName, nil); err != nil { + cs, err := sqlutil.ParseFileURI(dataSourceName) + if err != nil { + return nil, err + } + if d.db, err = sqlutil.Open(internal.SQLiteDriverName(), cs, nil); err != nil { return nil, err } if err = d.statements.prepare(d.db); err != nil { diff --git a/mediaapi/storage/storage_wasm.go b/mediaapi/storage/storage_wasm.go index aa188997..78de2cb8 100644 --- a/mediaapi/storage/storage_wasm.go +++ b/mediaapi/storage/storage_wasm.go @@ -35,7 +35,7 @@ func Open( case "postgres": return nil, fmt.Errorf("Cannot use postgres implementation") case "file": - return sqlite3.Open(uri.Path) + return sqlite3.Open(dataSourceName) default: return nil, fmt.Errorf("Cannot use postgres implementation") } |