mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-06-23 15:30:45 -04:00
Edit book: Fix a regression in the previous release that broke saving a copy of the current book on linux and OS X
This commit is contained in:
parent
e6e4a61ecc
commit
a0d19d2f40
@ -6,7 +6,7 @@ from __future__ import (unicode_literals, division, absolute_import,
|
|||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
__copyright__ = '2013, Kovid Goyal <kovid at kovidgoyal.net>'
|
__copyright__ = '2013, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||||
|
|
||||||
import shutil, os
|
import shutil, os, errno
|
||||||
from threading import Thread
|
from threading import Thread
|
||||||
from Queue import LifoQueue, Empty
|
from Queue import LifoQueue, Empty
|
||||||
|
|
||||||
@ -25,7 +25,14 @@ def save_container(container, path):
|
|||||||
if hasattr(os, 'fchmod'):
|
if hasattr(os, 'fchmod'):
|
||||||
# Ensure file permissions and owner information is preserved
|
# Ensure file permissions and owner information is preserved
|
||||||
fno = temp.fileno()
|
fno = temp.fileno()
|
||||||
|
try:
|
||||||
st = os.stat(path)
|
st = os.stat(path)
|
||||||
|
except EnvironmentError as err:
|
||||||
|
if err.errno != errno.ENOENT:
|
||||||
|
raise
|
||||||
|
# path may not exist if we are saving a copy, in which case we use
|
||||||
|
# the metadata from the original book
|
||||||
|
st = os.stat(container.path_to_ebook)
|
||||||
os.fchmod(fno, st.st_mode)
|
os.fchmod(fno, st.st_mode)
|
||||||
os.fchown(fno, st.st_uid, st.st_gid)
|
os.fchown(fno, st.st_uid, st.st_gid)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user