diff --git a/app/ui/backup.py b/app/ui/backup.py index 0a88fca6..e6de461c 100644 --- a/app/ui/backup.py +++ b/app/ui/backup.py @@ -59,14 +59,13 @@ class BackupDialog: def show(self): self._dialog_window.show() + @run_idle def init_data(self): - try: - files = os.listdir(self._backup_path) - except FileNotFoundError as e: - self.show_info_message(str(e), Gtk.MessageType.ERROR) - else: - for file in filter(lambda x: x.endswith(".zip"), files): + if os.path.isdir(self._backup_path): + for file in filter(lambda x: x.endswith(".zip"), os.listdir(self._backup_path)): self._model.append((file.rstrip(".zip"), False)) + else: + os.makedirs(os.path.dirname(self._backup_path), exist_ok=True) def on_restore_bouquets(self, item): self.restore(RestoreType.BOUQUETS) @@ -129,6 +128,8 @@ class BackupDialog: append_text_to_tview(name + "\n", self._text_view) except FileNotFoundError as e: self.show_info_message(str(e), Gtk.MessageType.ERROR) + else: + self._text_view.get_buffer().set_text("") def restore(self, restore_type): model, paths = self._main_view.get_selection().get_selected_rows() diff --git a/app/ui/main_app_window.py b/app/ui/main_app_window.py index 599b9cd0..5c79ea63 100644 --- a/app/ui/main_app_window.py +++ b/app/ui/main_app_window.py @@ -909,7 +909,6 @@ class Application(Gtk.Application): self._wait_dialog.show(get_message("Sorting data...")) GLib.idle_add(self.sort_fav, c_num, bq, paths, order, 0 if c_num == Column.FAV_NUM else "") - @run_idle def sort_fav(self, c_num, bq, paths, rev=False, nv=""): """ Sorting function for the bouquet details list.