From a19441dc88c7b72646a63b70ea6e476d6e7c6b1e Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 21 Dec 2014 10:22:56 +0530 Subject: [PATCH] Apparently there exist a lot of Macs out there with completely broken permissions on the home folders. Workaround that. --- src/calibre/utils/lock.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/calibre/utils/lock.py b/src/calibre/utils/lock.py index 336f5bb1b3..eac1a3ee77 100644 --- a/src/calibre/utils/lock.py +++ b/src/calibre/utils/lock.py @@ -224,7 +224,13 @@ elif islinux: return True else: def singleinstance_path(name): - return os.path.expanduser('~/.'+__appname__+'_'+name+'.lock') + home = os.path.expanduser('~') + if os.access(home, os.W_OK|os.R_OK|os.X_OK): + basename = __appname__+'_'+name+'.lock' + return os.path.expanduser('~/.' + basename) + import tempfile + tdir = tempfile.gettempdir() + return os.path.join(tdir, '%s_%s_%s.lock' % (__appname__, name, os.geteuid())) def singleinstance(name): '''