mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 18:54:09 -04:00
Fix #6672 (no write access to ~/.config/calibre)
This commit is contained in:
parent
a545bd1d81
commit
5270022152
@ -84,6 +84,9 @@ if plugins is None:
|
||||
# }}}
|
||||
|
||||
# config_dir {{{
|
||||
|
||||
CONFIG_DIR_MODE = 0700
|
||||
|
||||
if os.environ.has_key('CALIBRE_CONFIG_DIRECTORY'):
|
||||
config_dir = os.path.abspath(os.environ['CALIBRE_CONFIG_DIRECTORY'])
|
||||
elif iswindows:
|
||||
@ -98,7 +101,11 @@ elif isosx:
|
||||
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):
|
||||
try:
|
||||
os.makedirs(config_dir, mode=CONFIG_DIR_MODE)
|
||||
except:
|
||||
pass
|
||||
if not os.access(config_dir, os.W_OK) or not os.access(config_dir, os.X_OK):
|
||||
print 'No write acces to', config_dir, 'using a temporary dir instead'
|
||||
import tempfile, atexit
|
||||
config_dir = tempfile.mkdtemp(prefix='calibre-config-')
|
||||
|
@ -13,14 +13,12 @@ from optparse import OptionParser as _OptionParser
|
||||
from optparse import IndentedHelpFormatter
|
||||
from collections import defaultdict
|
||||
|
||||
from calibre.constants import terminal_controller, config_dir, \
|
||||
from calibre.constants import terminal_controller, config_dir, CONFIG_DIR_MODE, \
|
||||
__appname__, __version__, __author__
|
||||
from calibre.utils.lock import LockError, ExclusiveFile
|
||||
|
||||
plugin_dir = os.path.join(config_dir, 'plugins')
|
||||
|
||||
CONFIG_DIR_MODE = 0700
|
||||
|
||||
def make_config_dir():
|
||||
if not os.path.exists(plugin_dir):
|
||||
os.makedirs(plugin_dir, mode=CONFIG_DIR_MODE)
|
||||
|
Loading…
x
Reference in New Issue
Block a user