mirror of
https://github.com/Li4n0/revsuit.git
synced 2026-09-25 16:11:53 +08:00
fix: fix the error of database is locked when use sqlite (#60)
This commit is contained in:
@@ -40,6 +40,13 @@ func NewRecord(rule *Rule, flag, path, ip, area string) (r *Record, err error) {
|
||||
Path: path,
|
||||
Rule: *rule,
|
||||
}
|
||||
|
||||
// sqlite db-level lock to prevent too much write operation lead to error of `database is locked` #54
|
||||
if database.Driver == database.Sqlite {
|
||||
database.Locker.Lock()
|
||||
defer database.Locker.Unlock()
|
||||
}
|
||||
|
||||
return r, database.DB.Create(r).Error
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user