Commit 571abda0 authored by Dan Pascu's avatar Dan Pascu

Restore contacts from backup when corrupted during load

parent c3eb6784
...@@ -636,8 +636,14 @@ class ContactModel(QAbstractListModel): ...@@ -636,8 +636,14 @@ class ContactModel(QAbstractListModel):
file = open(ApplicationData.get('contacts')) file = open(ApplicationData.get('contacts'))
items = pickle.load(file) items = pickle.load(file)
except Exception: except Exception:
# remove the corrupted contacts file, so it won't be backed up to contacts.bak later
try:
os.unlink(ApplicationData.get('contacts'))
except Exception:
pass
file = open(ApplicationData.get('contacts.bak')) file = open(ApplicationData.get('contacts.bak'))
items = pickle.load(file) items = pickle.load(file)
file = None # restore contacts from contacts.bak
except Exception: except Exception:
file = None file = None
group = ContactGroup('Test') group = ContactGroup('Test')
......
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