From 1657dfec2410833ca6c37e0b81d35e4cb87c8812 Mon Sep 17 00:00:00 2001 From: Jonathan Warren Date: Wed, 26 Jun 2013 13:35:53 -0400 Subject: [PATCH] Move code related to settings file upgrade --- src/class_sqlThread.py | 18 +++++++++++++++++- src/helper_startup.py | 16 ---------------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/class_sqlThread.py b/src/class_sqlThread.py index 5848e868..ebe6a7ff 100644 --- a/src/class_sqlThread.py +++ b/src/class_sqlThread.py @@ -69,6 +69,22 @@ class sqlThread(threading.Thread): 'ERROR trying to create database file (message.dat). Error message: %s\n' % str(err)) os._exit(0) + if shared.config.getint('bitmessagesettings', 'settingsversion') == 1: + shared.config.set('bitmessagesettings', 'settingsversion', '2') + # If the settings version is equal to 2 or 3 then the + # sqlThread will modify the pubkeys table and change + # the settings version to 4. + shared.config.set('bitmessagesettings', 'socksproxytype', 'none') + shared.config.set('bitmessagesettings', 'sockshostname', 'localhost') + shared.config.set('bitmessagesettings', 'socksport', '9050') + shared.config.set('bitmessagesettings', 'socksauthentication', 'false') + shared.config.set('bitmessagesettings', 'socksusername', '') + shared.config.set('bitmessagesettings', 'sockspassword', '') + shared.config.set('bitmessagesettings', 'keysencrypted', 'false') + shared.config.set('bitmessagesettings', 'messagesencrypted', 'false') + with open(shared.appdata + 'keys.dat', 'wb') as configfile: + shared.config.write(configfile) + # People running earlier versions of PyBitmessage do not have the # usedpersonally field in their pubkeys table. Let's add it. if shared.config.getint('bitmessagesettings', 'settingsversion') == 2: @@ -158,7 +174,7 @@ class sqlThread(threading.Thread): self.cur.execute( ''' VACUUM ''') # After code refactoring, the possible status values for sent messages - # as changed. + # have changed. self.cur.execute( '''update sent set status='doingmsgpow' where status='doingpow' ''') self.cur.execute( diff --git a/src/helper_startup.py b/src/helper_startup.py index 08f8d48a..e6590b0e 100644 --- a/src/helper_startup.py +++ b/src/helper_startup.py @@ -76,19 +76,3 @@ def loadConfig(): os.makedirs(shared.appdata) with open(shared.appdata + 'keys.dat', 'wb') as configfile: shared.config.write(configfile) - - if shared.config.getint('bitmessagesettings', 'settingsversion') == 1: - shared.config.set('bitmessagesettings', 'settingsversion', '4') - # If the settings version is equal to 2 or 3 then the - # sqlThread will modify the pubkeys table and change - # the settings version to 4. - shared.config.set('bitmessagesettings', 'socksproxytype', 'none') - shared.config.set('bitmessagesettings', 'sockshostname', 'localhost') - shared.config.set('bitmessagesettings', 'socksport', '9050') - shared.config.set('bitmessagesettings', 'socksauthentication', 'false') - shared.config.set('bitmessagesettings', 'socksusername', '') - shared.config.set('bitmessagesettings', 'sockspassword', '') - shared.config.set('bitmessagesettings', 'keysencrypted', 'false') - shared.config.set('bitmessagesettings', 'messagesencrypted', 'false') - with open(shared.appdata + 'keys.dat', 'wb') as configfile: - shared.config.write(configfile)