fix a crash when saving a folder

This commit is contained in:
Lionel Dricot 2022-03-19 12:17:02 +01:00
parent 1e16c415fd
commit 517e0f0e9e
2 changed files with 9 additions and 2 deletions

View File

@ -1,5 +1,8 @@
# Offpunk History # Offpunk History
## 1.2 - Unreleased
- Fixed a crash when trying to save a folder
## 1.1 - March 18th 2022 ## 1.1 - March 18th 2022
- Perfect rendering of pictures with chafa 1.8+ and compatible terminal (Kitty) - Perfect rendering of pictures with chafa 1.8+ and compatible terminal (Kitty)
- timg is supported as an alternative to chafa (with a little glitch) - timg is supported as an alternative to chafa (with a little glitch)

View File

@ -3214,8 +3214,12 @@ see "handler" command to set your own."""
# Don't use _get_active_tmpfile() here, because we want to save the # Don't use _get_active_tmpfile() here, because we want to save the
# "source code" of menus, not the rendered view - this way Offpunk # "source code" of menus, not the rendered view - this way Offpunk
# can navigate to it later. # can navigate to it later.
print("Saved to %s" % filename) path = gi.get_body(as_file=True)
shutil.copyfile(gi.get_body(as_file=True), filename) if os.path.isdir(path):
print("Cant save %s because its a folder, not a file"%path)
else:
print("Saved to %s" % filename)
shutil.copyfile(path, filename)
# Restore gi if necessary # Restore gi if necessary
if index != None: if index != None: