mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-14 08:34:39 +00:00
Services: Intrusion Detection: Administration - Improve locking during sqlite db creation a bit.
If we remove the file, others will keep bashing the inode. Truncating should prevent that from happening.
This commit is contained in:
parent
70df688a9b
commit
2bac4f10a5
@ -243,9 +243,13 @@ class RuleCache(object):
|
||||
fcntl.flock(lock, fcntl.LOCK_UN)
|
||||
return
|
||||
|
||||
# remove existing DB
|
||||
# remove (truncate) existing DB
|
||||
if os.path.exists(self.cachefile):
|
||||
os.remove(self.cachefile)
|
||||
fhandle = open(self.cachefile, 'a+')
|
||||
fhandle.seek(0)
|
||||
fhandle.truncate()
|
||||
fhandle.close()
|
||||
|
||||
|
||||
db = sqlite3.connect(self.cachefile)
|
||||
db.text_factory = lambda x: str(x, 'utf-8', 'ignore')
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user