Fix #810655 (unable to add new books to calibre on win7)

This commit is contained in:
Kovid Goyal 2011-07-14 12:47:14 -06:00
parent 0e877521b2
commit 79b1c42db0

View File

@ -114,7 +114,17 @@ def PersistentTemporaryDirectory(suffix='', prefix='', dir=None):
''' '''
if dir is None: if dir is None:
dir = base_dir() dir = base_dir()
tdir = tempfile.mkdtemp(suffix, __appname__+"_"+ __version__+"_" +prefix, dir) try:
tdir = tempfile.mkdtemp(suffix, __appname__+"_"+ __version__+"_" +prefix, dir)
except ValueError:
global _base_dir
from calibre.constants import filesystem_encoding
base_dir()
if not isinstance(_base_dir, unicode):
_base_dir = _base_dir.decode(filesystem_encoding)
dir = dir.decode(filesystem_encoding)
tdir = tempfile.mkdtemp(suffix, __appname__+"_"+ __version__+"_" +prefix, dir)
atexit.register(remove_dir, tdir) atexit.register(remove_dir, tdir)
return tdir return tdir