From ea974217e64f4a492369a917948aeffb048916bd Mon Sep 17 00:00:00 2001 From: niknah Date: Tue, 28 Dec 2021 20:33:03 +1100 Subject: [PATCH] Don't lose video if we don't have permission or the destination goes missing. https://github.com/hzbd/kazam/issues/70 --- kazam/app.py | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/kazam/app.py b/kazam/app.py index e332e42..c47669f 100644 --- a/kazam/app.py +++ b/kazam/app.py @@ -788,6 +788,19 @@ def stop_request(self): return True return False + def AskSaveRecording(self): + self.done_recording = DoneRecording(self.icons, + self.tempfile, + prefs.codec, + self.old_vid_path) + logger.debug("Done Recording initialized.") + self.done_recording.connect("save-done", self.cb_save_done) + self.done_recording.connect("save-cancel", self.cb_save_cancel) + self.done_recording.connect("edit-request", self.cb_edit_request) + logger.debug("Done recording signals connected.") + self.done_recording.show_all() + self.window.set_sensitive(False) + def cb_flush_done(self, widget): if self.main_mode == MODE_SCREENCAST and prefs.autosave_video: logger.debug("Autosaving enabled.") @@ -796,7 +809,11 @@ def cb_flush_done(self, widget): CODEC_LIST[prefs.codec][3]) if os.path.isfile(self.tempfile): - shutil.move(self.tempfile, fname) + try: + shutil.move(self.tempfile, fname) + except Exception as e: + logger.error("Could not autosave, ask for save location instead: {}".format(e)) + self.AskSaveRecording() else: logger.error("Cannot find autosave file: {}".format(self.tempfile)) @@ -818,17 +835,7 @@ def cb_flush_done(self, widget): self.window.show() self.window.present() elif self.main_mode == MODE_SCREENCAST or self.main_mode == MODE_WEBCAM: - self.done_recording = DoneRecording(self.icons, - self.tempfile, - prefs.codec, - self.old_vid_path) - logger.debug("Done Recording initialized.") - self.done_recording.connect("save-done", self.cb_save_done) - self.done_recording.connect("save-cancel", self.cb_save_cancel) - self.done_recording.connect("edit-request", self.cb_edit_request) - logger.debug("Done recording signals connected.") - self.done_recording.show_all() - self.window.set_sensitive(False) + self.AskSaveRecording() elif self.main_mode == MODE_BROADCAST: self.window.set_sensitive(True)