mirror of
https://github.com/ddworken/hishtory.git
synced 2025-02-17 02:50:49 +01: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,
|
||||
},
|
||||
)
|
||||
// TODO: should I specify WAL here: https://stackoverflow.com/questions/57118674/go-sqlite3-with-journal-mode-wal-gives-database-is-locked-error
|
||||
db, err := gorm.Open(sqlite.Open(path.Join(homedir, data.HISHTORY_PATH, data.DB_PATH)), &gorm.Config{SkipDefaultTransaction: true, Logger: newLogger})
|
||||
dbFilePath := path.Join(homedir, data.HISHTORY_PATH, data.DB_PATH)
|
||||
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 {
|
||||
return nil, fmt.Errorf("failed to connect to the DB: %v", err)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user