mirror of
https://github.com/ddworken/hishtory.git
synced 2025-06-04 20:27:00 +02:00
Specify WAL when opening the sqlite file to defend against deadlocks
This commit is contained in:
parent
6e7822ebae
commit
e3a793c753
@ -86,8 +86,9 @@ func OpenLocalSqliteDb() (*gorm.DB, error) {
|
|||||||
Colorful: false,
|
Colorful: false,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
// TODO: should I specify WAL here: https://stackoverflow.com/questions/57118674/go-sqlite3-with-journal-mode-wal-gives-database-is-locked-error
|
dbFilePath := path.Join(homedir, data.HISHTORY_PATH, data.DB_PATH)
|
||||||
db, err := gorm.Open(sqlite.Open(path.Join(homedir, data.HISHTORY_PATH, data.DB_PATH)), &gorm.Config{SkipDefaultTransaction: true, Logger: newLogger})
|
dsn := fmt.Sprintf("file:%s?cache=shared&mode=rwc&_journal_mode=WAL", dbFilePath)
|
||||||
|
db, err := gorm.Open(sqlite.Open(dsn), &gorm.Config{SkipDefaultTransaction: true, Logger: newLogger})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to connect to the DB: %v", err)
|
return nil, fmt.Errorf("failed to connect to the DB: %v", err)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user