mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04: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
@ -98,5 +98,16 @@ elif isosx:
|
|||||||
else:
|
else:
|
||||||
bdir = os.path.abspath(os.path.expanduser(os.environ.get('XDG_CONFIG_HOME', '~/.config')))
|
bdir = os.path.abspath(os.path.expanduser(os.environ.get('XDG_CONFIG_HOME', '~/.config')))
|
||||||
config_dir = os.path.join(bdir, 'calibre')
|
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…
x
Reference in New Issue
Block a user