Portable mode fixes
Fixes Bitmessage#379, Bitmessage#341
This commit is contained in:
parent
4f6fd07424
commit
5a45d7dd8f
|
@ -2708,18 +2708,18 @@ class MyForm(settingsmixin.SMainWindow):
|
|||
if shared.appdata != '' and self.settingsDialogInstance.ui.checkBoxPortableMode.isChecked(): # If we are NOT using portable mode now but the user selected that we should...
|
||||
# Write the keys.dat file to disk in the new location
|
||||
sqlStoredProcedure('movemessagstoprog')
|
||||
with open('keys.dat', 'wb') as configfile:
|
||||
with open(shared.lookupExeFolder() + 'keys.dat', 'wb') as configfile:
|
||||
shared.config.write(configfile)
|
||||
# Write the knownnodes.dat file to disk in the new location
|
||||
shared.knownNodesLock.acquire()
|
||||
output = open('knownnodes.dat', 'wb')
|
||||
output = open(shared.lookupExeFolder() + 'knownnodes.dat', 'wb')
|
||||
pickle.dump(shared.knownNodes, output)
|
||||
output.close()
|
||||
shared.knownNodesLock.release()
|
||||
os.remove(shared.appdata + 'keys.dat')
|
||||
os.remove(shared.appdata + 'knownnodes.dat')
|
||||
previousAppdataLocation = shared.appdata
|
||||
shared.appdata = ''
|
||||
shared.appdata = shared.lookupExeFolder()
|
||||
debug.restartLoggingInUpdatedAppdataLocation()
|
||||
try:
|
||||
os.remove(previousAppdataLocation + 'debug.log')
|
||||
|
@ -2740,12 +2740,12 @@ class MyForm(settingsmixin.SMainWindow):
|
|||
pickle.dump(shared.knownNodes, output)
|
||||
output.close()
|
||||
shared.knownNodesLock.release()
|
||||
os.remove('keys.dat')
|
||||
os.remove('knownnodes.dat')
|
||||
os.remove(shared.lookupExeFolder() + 'keys.dat')
|
||||
os.remove(shared.lookupExeFolder() + 'knownnodes.dat')
|
||||
debug.restartLoggingInUpdatedAppdataLocation()
|
||||
try:
|
||||
os.remove('debug.log')
|
||||
os.remove('debug.log.1')
|
||||
os.remove(shared.lookupExeFolder() + 'debug.log')
|
||||
os.remove(shared.lookupExeFolder() + 'debug.log.1')
|
||||
except:
|
||||
pass
|
||||
|
||||
|
|
|
@ -501,8 +501,8 @@ class sqlThread(threading.Thread):
|
|||
return
|
||||
self.conn.close()
|
||||
shutil.move(
|
||||
shared.lookupAppdataFolder() + 'messages.dat', 'messages.dat')
|
||||
self.conn = sqlite3.connect('messages.dat')
|
||||
shared.lookupAppdataFolder() + 'messages.dat', shared.lookupExeFolder() + 'messages.dat')
|
||||
self.conn = sqlite3.connect(shared.lookupExeFolder() + 'messages.dat')
|
||||
self.conn.text_factory = str
|
||||
self.cur = self.conn.cursor()
|
||||
elif item == 'movemessagstoappdata':
|
||||
|
@ -520,8 +520,8 @@ class sqlThread(threading.Thread):
|
|||
return
|
||||
self.conn.close()
|
||||
shutil.move(
|
||||
'messages.dat', shared.lookupAppdataFolder() + 'messages.dat')
|
||||
self.conn = sqlite3.connect(shared.appdata + 'messages.dat')
|
||||
shared.lookupExeFolder() + 'messages.dat', shared.lookupAppdataFolder() + 'messages.dat')
|
||||
self.conn = sqlite3.connect(shared.lookupAppdataFolder() + 'messages.dat')
|
||||
self.conn.text_factory = str
|
||||
self.cur = self.conn.cursor()
|
||||
elif item == 'deleteandvacuume':
|
||||
|
|
|
@ -35,12 +35,12 @@ def loadConfig():
|
|||
needToCreateKeysFile = True
|
||||
|
||||
else:
|
||||
shared.config.read('keys.dat')
|
||||
shared.config.read(shared.lookupExeFolder() + 'keys.dat'))
|
||||
try:
|
||||
shared.config.get('bitmessagesettings', 'settingsversion')
|
||||
print 'Loading config files from same directory as program.'
|
||||
needToCreateKeysFile = False
|
||||
shared.appdata = ''
|
||||
shared.appdata = shared.lookupExeFolder()
|
||||
except:
|
||||
# Could not load the keys.dat file in the program directory. Perhaps it
|
||||
# is in the appdata directory.
|
||||
|
|
|
@ -198,6 +198,15 @@ def assembleErrorMessage(fatal=0, banTime=0, inventoryVector='', errorText=''):
|
|||
payload += errorText
|
||||
return CreatePacket('error', payload)
|
||||
|
||||
def lookupExeFolder():
|
||||
if frozen:
|
||||
exeFolder = os.path.join(os.path.dirname(sys.executable), '/')
|
||||
elif __file__:
|
||||
exeFolder = os.path.join(os.path.dirname(__file__), '/')
|
||||
else:
|
||||
exeFolder = ''
|
||||
return exeFolder
|
||||
|
||||
def lookupAppdataFolder():
|
||||
APPNAME = "PyBitmessage"
|
||||
if "BITMESSAGE_HOME" in environ:
|
||||
|
|
Reference in New Issue
Block a user