mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
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:
parent
2f8c415f49
commit
66c4618556
@ -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:
|
||||
|
Loading…
x
Reference in New Issue
Block a user