mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-11-25 14:33:32 -06:00
[bugfix] Fix loss of account info on export/import, add tests (#759)
* start adding additional tests * use random database address for in-memory sqlite * add more fields to account export
This commit is contained in:
parent
570fa7c359
commit
b96533ca8f
4 changed files with 74 additions and 10 deletions
|
|
@ -31,6 +31,7 @@ import (
|
|||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/jackc/pgx/v4"
|
||||
"github.com/jackc/pgx/v4/stdlib"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/cache"
|
||||
|
|
@ -229,6 +230,15 @@ func sqliteConn(ctx context.Context) (*DBConn, error) {
|
|||
// Append our own SQLite preferences
|
||||
dbAddress = "file:" + dbAddress + "?cache=shared"
|
||||
|
||||
var inMem bool
|
||||
|
||||
if dbAddress == "file::memory:?cache=shared" {
|
||||
dbAddress = fmt.Sprintf("file:%s?mode=memory&cache=shared", uuid.NewString())
|
||||
log.Infof("using in-memory database address " + dbAddress)
|
||||
log.Warn("sqlite in-memory database should only be used for debugging")
|
||||
inMem = true
|
||||
}
|
||||
|
||||
// Open new DB instance
|
||||
sqldb, err := sql.Open("sqlite", dbAddress)
|
||||
if err != nil {
|
||||
|
|
@ -240,8 +250,7 @@ func sqliteConn(ctx context.Context) (*DBConn, error) {
|
|||
|
||||
tweakConnectionValues(sqldb)
|
||||
|
||||
if dbAddress == "file::memory:?cache=shared" {
|
||||
log.Warn("sqlite in-memory database should only be used for debugging")
|
||||
if inMem {
|
||||
// don't close connections on disconnect -- otherwise
|
||||
// the SQLite database will be deleted when there
|
||||
// are no active connections
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue