Skip to content

Commit

Permalink
Show back notes after restore failure
Browse files Browse the repository at this point in the history
  • Loading branch information
j4321 committed Aug 14, 2018
1 parent ce106b5 commit 62503ae
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions mynoteslib/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -628,6 +628,7 @@ def restore(self, fichier=None, confirmation=True):
dp = pickle.Unpickler(myfich)
note_data = dp.load()
keys = list(self.note_data.keys())
visible_notes = list(self.notes.keys())
self.hide_all()
self._load_notes(note_data)
if not os.path.samefile(fichier, PATH_DATA):
Expand All @@ -637,16 +638,21 @@ def restore(self, fichier=None, confirmation=True):
except pickle.UnpicklingError:
try:
keys = list(self.note_data.keys())
visible_notes = list(self.notes.keys())
self.hide_all()
self._load_notes_with_data(fichier, cleanup_cat=True)
for key in keys:
self.delete_note(key)
except Exception:
for key in visible_notes:
self.show_note(key)
message = _("The file {file} is not a valid note archive.").format(file=fichier)
showerror(_("Error"), message, traceback.format_exc())
except FileNotFoundError:
showerror(_("Error"), _("The file {filename} does not exists.").format(filename=fichier))
except Exception:
for key in visible_notes:
self.show_note(key)
message = _("The file {file} is not a valid .notes file.").format(file=fichier)
showerror(_("Error"), message, traceback.format_exc())

Expand Down

0 comments on commit 62503ae

Please sign in to comment.