Rev1905, Secure DB write db_mode option

This commit is contained in:
shortcutme 2017-02-15 12:43:05 +01:00
parent 3d55af2111
commit f5fb6b83ff
No known key found for this signature in database
GPG key ID: 5B63BAE6CB9613AE
2 changed files with 8 additions and 4 deletions

View file

@ -10,7 +10,7 @@ class Config(object):
def __init__(self, argv): def __init__(self, argv):
self.version = "0.5.2" self.version = "0.5.2"
self.rev = 1899 self.rev = 1905
self.argv = argv self.argv = argv
self.action = None self.action = None
self.config_file = "zeronet.conf" self.config_file = "zeronet.conf"
@ -206,6 +206,7 @@ class Config(object):
type='bool', choices=[True, False], default=True) type='bool', choices=[True, False], default=True)
self.parser.add_argument("--fix_float_decimals", help='Fix content.json modification date float precision on verification', self.parser.add_argument("--fix_float_decimals", help='Fix content.json modification date float precision on verification',
type='bool', choices=[True, False], default=fix_float_decimals) type='bool', choices=[True, False], default=fix_float_decimals)
self.parser.add_argument("--db_mode", choices=["speed", "security"], default="speed")
self.parser.add_argument('--coffeescript_compiler', help='Coffeescript compiler for developing', default=coffeescript, self.parser.add_argument('--coffeescript_compiler', help='Coffeescript compiler for developing', default=coffeescript,
metavar='executable_path') metavar='executable_path')

View file

@ -59,9 +59,12 @@ class Db(object):
self.conn.row_factory = sqlite3.Row self.conn.row_factory = sqlite3.Row
self.conn.isolation_level = None self.conn.isolation_level = None
self.cur = self.getCursor() self.cur = self.getCursor()
# We need more speed then security if config.db_mode == "security":
self.cur.execute("PRAGMA journal_mode = MEMORY") self.cur.execute("PRAGMA journal_mode = WAL")
self.cur.execute("PRAGMA synchronous = OFF") self.cur.execute("PRAGMA synchronous = NORMAL")
else:
self.cur.execute("PRAGMA journal_mode = MEMORY")
self.cur.execute("PRAGMA synchronous = OFF")
if self.foreign_keys: if self.foreign_keys:
self.execute("PRAGMA foreign_keys = ON") self.execute("PRAGMA foreign_keys = ON")
self.log.debug( self.log.debug(