Do not mask the correct exception when failing to create the backup metadata.opf file

This commit is contained in:
Kovid Goyal 2015-01-25 05:05:03 +05:30
parent 18bd7879ed
commit f0ca2c0cc3

View File

@ -8,7 +8,7 @@ __copyright__ = '2011, Kovid Goyal <kovid@kovidgoyal.net>'
__docformat__ = 'restructuredtext en' __docformat__ = 'restructuredtext en'
# Imports {{{ # Imports {{{
import os, shutil, uuid, json, glob, time, cPickle, hashlib, errno import os, shutil, uuid, json, glob, time, cPickle, hashlib, errno, sys
from functools import partial from functools import partial
import apsw import apsw
@ -1538,7 +1538,14 @@ class DB(object):
with lopen(path, 'wb') as f: with lopen(path, 'wb') as f:
f.write(raw) f.write(raw)
except EnvironmentError: except EnvironmentError:
exc_info = sys.exc_info()
try:
os.makedirs(os.path.dirname(path)) os.makedirs(os.path.dirname(path))
except EnvironmentError as err:
if err.errno == errno.EEXIST:
# Parent directory already exists, re-raise original exception
raise exc_info[0], exc_info[1], exc_info[2]
raise
with lopen(path, 'wb') as f: with lopen(path, 'wb') as f:
f.write(raw) f.write(raw)