fix: fix the error of database is locked when use sqlite (#60)

This commit is contained in:
Li4n0
2022-09-14 01:08:42 +08:00
committed by GitHub
parent 3fa2cae862
commit d29b767d9c
7 changed files with 49 additions and 2 deletions
+7
View File
@@ -51,6 +51,13 @@ func newRecord(rule *Rule, flag, username, schema, clientName, clientOS, remoteI
Files: files,
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
}