mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
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:
parent
44822799be
commit
eea4dddc32
@ -34,7 +34,14 @@ def save_container(container, path):
|
|||||||
# the metadata from the original book
|
# the metadata from the original book
|
||||||
st = os.stat(container.path_to_ebook)
|
st = os.stat(container.path_to_ebook)
|
||||||
os.fchmod(fno, st.st_mode)
|
os.fchmod(fno, st.st_mode)
|
||||||
|
try:
|
||||||
os.fchown(fno, st.st_uid, st.st_gid)
|
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.close()
|
||||||
temp = temp.name
|
temp = temp.name
|
||||||
|
Loading…
x
Reference in New Issue
Block a user