Fix #1513849 [Edit E-Book will not save after editing if original file is not in its directory.](https://bugs.launchpad.net/calibre/+bug/1513849)

This commit is contained in:
Kovid Goyal 2015-11-06 20:25:24 +05:30
parent 2f8c415f49
commit 66c4618556

View File

@ -34,6 +34,7 @@ def save_container(container, path):
if hasattr(os, 'fchmod'):
# Ensure file permissions and owner information is preserved
fno = temp.fileno()
st = None
try:
st = os.stat(path)
except EnvironmentError as err:
@ -41,7 +42,13 @@ def save_container(container, path):
raise
# path may not exist if we are saving a copy, in which case we use
# the metadata from the original book
try:
st = os.stat(container.path_to_ebook)
except EnvironmentError as err:
if err.errno != errno.ENOENT:
raise
# Somebody deleted the original file
if st is not None:
try:
os.fchmod(fno, st.st_mode)
except EnvironmentError as err: