Commit c9d88965 authored by David Johnson's avatar David Johnson

Fix bugs with database file handling.

parent 86cd96d1
Pipeline #3008 passed with stages
in 14 seconds
......@@ -279,8 +279,13 @@ class NlSdnConfig(ConfigSection):
self.dbfile = jsonblob["dbfile"]
self.dbfile = "/var/lib/nlsdn/db.json"
if not os.access(self.dbfile,os.W_OK | os.R_OK):
if os.path.exists(self.dbfile) \
and not os.access(self.dbfile,os.W_OK | os.R_OK):
raise ConfigError(
"cannot read/write nlsdn dbfile '%s'" % (self.dbfile,))
elif not os.path.exists(os.path.dirname(self.dbfile)) \
or not os.access(os.path.dirname(self.dbfile),os.W_OK | os.R_OK):
raise ConfigError(
"cannot read/write nlsdn dbfile dir '%s'" % (os.path.dirname(self.dbfile),))
import os
import sys
import json
from nlsdn.util import CustomJsonEncoder
......@@ -233,8 +234,9 @@ class Engine(object):
def load(self,force=False,ensure=True):
if self._loaded and not force:
fd = file(self.path,'r')
raw = ""
if os.path.exists(self.path):
fd = file(self.path,'r')
while True:
x =
if not x:
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment