mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix #4426 (Error opening epub for view)
This commit is contained in:
parent
536e629356
commit
8bfffc74e2
@ -4,6 +4,7 @@ a zip archive.
|
|||||||
"""
|
"""
|
||||||
from __future__ import with_statement
|
from __future__ import with_statement
|
||||||
from calibre.ptempfile import TemporaryDirectory
|
from calibre.ptempfile import TemporaryDirectory
|
||||||
|
from calibre import sanitize_file_name
|
||||||
import struct, os, time, sys, shutil
|
import struct, os, time, sys, shutil
|
||||||
import binascii, cStringIO
|
import binascii, cStringIO
|
||||||
|
|
||||||
@ -1038,6 +1039,10 @@ class ZipFile:
|
|||||||
|
|
||||||
source = self.open(member, pwd=pwd)
|
source = self.open(member, pwd=pwd)
|
||||||
if not os.path.exists(targetpath): # Could be a previously automatically created directory
|
if not os.path.exists(targetpath): # Could be a previously automatically created directory
|
||||||
|
try:
|
||||||
|
target = open(targetpath, "wb")
|
||||||
|
except IOError:
|
||||||
|
targetpath = sanitize_file_name(targetpath)
|
||||||
target = open(targetpath, "wb")
|
target = open(targetpath, "wb")
|
||||||
shutil.copyfileobj(source, target)
|
shutil.copyfileobj(source, target)
|
||||||
source.close()
|
source.close()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user