Edit Book: When user is editing files belonging to another user account on linux/os x rather than erroring out when saving, change the ownership of the file to the editing user. Fixes #1299097 [Editing doesn't save changes since version 1.28](https://bugs.launchpad.net/calibre/+bug/1299097)

This commit is contained in:
Kovid Goyal 2014-03-29 08:38:02 +05:30
parent 44822799be
commit eea4dddc32

View File

@ -34,7 +34,14 @@ def save_container(container, path):
# the metadata from the original book
st = os.stat(container.path_to_ebook)
os.fchmod(fno, st.st_mode)
os.fchown(fno, st.st_uid, st.st_gid)
try:
os.fchown(fno, st.st_uid, st.st_gid)
except EnvironmentError as err:
if err.errno != errno.EPERM:
# ignore chown failure as user could be editing file belonging
# to a different user, in which case we really cant do anything
# about it short of making the file update non-atomic
raise
temp.close()
temp = temp.name