Make sure keyboard interrupted renders don't overwrite pre-existing video files

This commit is contained in:
Grant Sanderson 2022-05-11 12:48:08 -07:00
parent 11d19b6d57
commit f741217c34
2 changed files with 7 additions and 2 deletions

View file

@ -124,6 +124,7 @@ class Scene(object):
except KeyboardInterrupt:
# Get rid keyboard interupt symbols
print("", end="\r")
self.file_writer.ended_with_interrupt = True
self.tear_down()
def setup(self) -> None:
@ -190,7 +191,6 @@ class Scene(object):
# As long as the copied selection starts with a comment,
# this will revert to the state of the scene at the first
# point of running.
def checkpoint_paste(skip=False, show_progress=False):
def checkpoint_paste(skip=False, show_progress=True):
pasted = pyperclip.paste()
line0 = pasted.lstrip().split("\n")[0]

View file

@ -54,6 +54,7 @@ class SceneFileWriter(object):
self.scene: Scene = scene
self.writing_process: sp.Popen | None = None
self.has_progress_display: bool = False
self.ended_with_interrupt: bool = False
self.init_output_directories()
self.init_audio()
@ -297,7 +298,11 @@ class SceneFileWriter(object):
self.writing_process.terminate()
if self.has_progress_display:
self.progress_display.close()
if not self.ended_with_interrupt:
shutil.move(self.temp_file_path, self.final_file_path)
else:
self.movie_file_path = self.temp_file_path
def combine_movie_files(self) -> None:
kwargs = {