mirror of
git://github.com/kovidgoyal/calibre.git
synced 2025-12-20 17:06:06 +01: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
1 changed files with 9 additions and 2 deletions
|
|
@ -6,7 +6,7 @@
|
|||
__license__ = 'GPL v3'
|
||||
__copyright__ = '2013, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||
|
||||
import shutil, os
|
||||
import shutil, os, errno
|
||||
from threading import Thread
|
||||
from Queue import LifoQueue, Empty
|
||||
|
||||
|
|
@ -25,7 +25,14 @@ def save_container(container, path):
|
|||
if hasattr(os, 'fchmod'):
|
||||
# Ensure file permissions and owner information is preserved
|
||||
fno = temp.fileno()
|
||||
st = os.stat(path)
|
||||
try:
|
||||
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.fchown(fno, st.st_uid, st.st_gid)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue