aboutsummaryrefslogtreecommitdiff
path: root/clientapi/auth
diff options
context:
space:
mode:
authorKegsay <kegan@matrix.org>2020-06-04 11:18:08 +0100
committerGitHub <noreply@github.com>2020-06-04 11:18:08 +0100
commite7d1ac84c32a10f8deb7bcfc94531386312179c7 (patch)
treecfb8176ebcd9cd1087aa1c34f6f362dd2851dcdc /clientapi/auth
parentd4f9a4bb97c0c66963d7fd9c1395614a2198112e (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 'clientapi/auth')
-rw-r--r--clientapi/auth/storage/accounts/sqlite3/storage.go6
-rw-r--r--clientapi/auth/storage/accounts/storage_wasm.go2
-rw-r--r--clientapi/auth/storage/devices/sqlite3/storage.go6
-rw-r--r--clientapi/auth/storage/devices/storage_wasm.go2
4 files changed, 12 insertions, 4 deletions
diff --git a/clientapi/auth/storage/accounts/sqlite3/storage.go b/clientapi/auth/storage/accounts/sqlite3/storage.go
index 5233001f..31426e47 100644
--- a/clientapi/auth/storage/accounts/sqlite3/storage.go
+++ b/clientapi/auth/storage/accounts/sqlite3/storage.go
@@ -48,7 +48,11 @@ type Database struct {
func NewDatabase(dataSourceName string, serverName gomatrixserverlib.ServerName) (*Database, error) {
var db *sql.DB
var err error
- if db, err = sqlutil.Open(internal.SQLiteDriverName(), dataSourceName, nil); err != nil {
+ cs, err := sqlutil.ParseFileURI(dataSourceName)
+ if err != nil {
+ return nil, err
+ }
+ if db, err = sqlutil.Open(internal.SQLiteDriverName(), cs, nil); err != nil {
return nil, err
}
partitions := internal.PartitionOffsetStatements{}
diff --git a/clientapi/auth/storage/accounts/storage_wasm.go b/clientapi/auth/storage/accounts/storage_wasm.go
index 7cf50de7..81e77cf7 100644
--- a/clientapi/auth/storage/accounts/storage_wasm.go
+++ b/clientapi/auth/storage/accounts/storage_wasm.go
@@ -36,7 +36,7 @@ func NewDatabase(
case "postgres":
return nil, fmt.Errorf("Cannot use postgres implementation")
case "file":
- return sqlite3.NewDatabase(uri.Path, serverName)
+ return sqlite3.NewDatabase(dataSourceName, serverName)
default:
return nil, fmt.Errorf("Cannot use postgres implementation")
}
diff --git a/clientapi/auth/storage/devices/sqlite3/storage.go b/clientapi/auth/storage/devices/sqlite3/storage.go
index 5cd89451..e05a53b4 100644
--- a/clientapi/auth/storage/devices/sqlite3/storage.go
+++ b/clientapi/auth/storage/devices/sqlite3/storage.go
@@ -41,7 +41,11 @@ type Database struct {
func NewDatabase(dataSourceName string, serverName gomatrixserverlib.ServerName) (*Database, error) {
var db *sql.DB
var err error
- if db, err = sqlutil.Open(internal.SQLiteDriverName(), dataSourceName, nil); err != nil {
+ cs, err := sqlutil.ParseFileURI(dataSourceName)
+ if err != nil {
+ return nil, err
+ }
+ if db, err = sqlutil.Open(internal.SQLiteDriverName(), cs, nil); err != nil {
return nil, err
}
d := devicesStatements{}
diff --git a/clientapi/auth/storage/devices/storage_wasm.go b/clientapi/auth/storage/devices/storage_wasm.go
index c89ad887..14c19e74 100644
--- a/clientapi/auth/storage/devices/storage_wasm.go
+++ b/clientapi/auth/storage/devices/storage_wasm.go
@@ -36,7 +36,7 @@ func NewDatabase(
case "postgres":
return nil, fmt.Errorf("Cannot use postgres implementation")
case "file":
- return sqlite3.NewDatabase(uri.Path, serverName)
+ return sqlite3.NewDatabase(dataSourceName, serverName)
default:
return nil, fmt.Errorf("Cannot use postgres implementation")
}