This commit is contained in:
Jonathan Warren 2014-12-25 21:06:10 -05:00
parent 50c392c197
commit 9b6bc26144
2 changed files with 10 additions and 4 deletions

View File

@ -2426,7 +2426,8 @@ class MyForm(QtGui.QMainWindow):
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')
shared.writeKeysFile()
with open('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')

View File

@ -850,12 +850,17 @@ def writeKeysFile():
fileName = shared.appdata + 'keys.dat'
fileNameBak = fileName + "." + datetime.datetime.now().strftime("%Y%j%H%M%S%f") + '.bak'
# create a backup copy to prevent the accidental loss due to the disk write failure
shutil.copyfile(fileName, fileNameBak)
try:
shutil.copyfile(fileName, fileNameBak)
# The backup succeeded. This can fail if the file didn't exist before.
existingFileNameExisted = True
except:
existingFileNameExisted = False
# write the file
with open(fileName, 'wb') as configfile:
shared.config.write(configfile)
# delete a backup
os.remove(fileNameBak)
if existingFileNameExisted:
os.remove(fileNameBak)
helper_startup.loadConfig()
from debug import logger