From 20b6ac053407c4f7f242cc18801dde672f96cebd Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 28 Jan 2018 09:06:56 +0530 Subject: [PATCH] tdir_in_cache() should return an empty dir --- src/calibre/utils/tdir_in_cache.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/calibre/utils/tdir_in_cache.py b/src/calibre/utils/tdir_in_cache.py index 2c97c49d28..1d8ed8dde9 100644 --- a/src/calibre/utils/tdir_in_cache.py +++ b/src/calibre/utils/tdir_in_cache.py @@ -103,7 +103,7 @@ def tdir_in_cache(base): ''' Create a temp dir inside cache_dir/base. The created dir is robust against application crashes. i.e. it will be cleaned up the next time the application starts, even if it was left behind by a previous crash. ''' - b = os.path.join(cache_dir(), base) + b = os.path.join(os.path.realpath(cache_dir()), base) try: os.makedirs(b) except EnvironmentError as e: @@ -121,6 +121,8 @@ def tdir_in_cache(base): tdir = tempfile.mkdtemp(dir=b) lock_data = lock_tdir(tdir) atexit.register(remove_tdir, tdir, lock_data) + tdir = os.path.join(tdir, 'a') + os.mkdir(tdir) return tdir finally: unlock_file(global_lock)