mirror of
git://github.com/kovidgoyal/calibre.git
synced 2026-05-08 22:43:31 +02:00
Linux environment: Use atemporary dir as the config directory if write access to the normal config directory is unavailable. Can be overriden by using the CALIBRE_CONFIG_DIRECTORY environment variable
This commit is contained in:
parent
0472411aea
commit
2e42090a0d
1 changed files with 11 additions and 0 deletions
|
|
@ -98,5 +98,16 @@ def load_plugins():
|
|||
else:
|
||||
bdir = os.path.abspath(os.path.expanduser(os.environ.get('XDG_CONFIG_HOME', '~/.config')))
|
||||
config_dir = os.path.join(bdir, 'calibre')
|
||||
if not os.access(config_dir, os.W_OK):
|
||||
print 'No write acces to', config_dir, 'using a temporary dir instead'
|
||||
import tempfile, atexit
|
||||
config_dir = tempfile.mkdtemp(prefix='calibre-config-')
|
||||
def cleanup_cdir():
|
||||
try:
|
||||
import shutil
|
||||
shutil.rmtree(config_dir)
|
||||
except:
|
||||
pass
|
||||
atexit.register(cleanup_cdir)
|
||||
# }}}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue