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
This commit is contained in:
Kegsay 2020-06-04 11:18:08 +01:00 committed by GitHub
parent d4f9a4bb97
commit e7d1ac84c3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 66 additions and 51 deletions

View file

@ -42,7 +42,11 @@ type attributeValue interface{}
func NewPublicRoomsServerDatabase(dataSourceName string, localServerName gomatrixserverlib.ServerName) (*PublicRoomsServerDatabase, 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
}
storage := PublicRoomsServerDatabase{

View file

@ -32,7 +32,7 @@ func NewPublicRoomsServerDatabase(dataSourceName string, localServerName gomatri
case "postgres":
return nil, fmt.Errorf("Cannot use postgres implementation")
case "file":
return sqlite3.NewPublicRoomsServerDatabase(uri.Path, localServerName)
return sqlite3.NewPublicRoomsServerDatabase(dataSourceName, localServerName)
default:
return nil, fmt.Errorf("Cannot use postgres implementation")
}