mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Prevent a malformed tweaks.json file from stopping calibre startup
This commit is contained in:
parent
7d6338caa8
commit
5a3678d8c6
@ -610,12 +610,20 @@ def exec_tweaks(path):
|
||||
def read_custom_tweaks():
|
||||
make_config_dir()
|
||||
tf = tweaks_file()
|
||||
ans = {}
|
||||
if os.path.exists(tf):
|
||||
with open(tf, 'rb') as f:
|
||||
raw = f.read()
|
||||
return json_loads(raw)
|
||||
raw = raw.strip()
|
||||
if not raw:
|
||||
return ans
|
||||
try:
|
||||
return json_loads(raw)
|
||||
except Exception:
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
return ans
|
||||
old_tweaks_file = tf.rpartition(u'.')[0] + u'.py'
|
||||
ans = {}
|
||||
if os.path.exists(old_tweaks_file):
|
||||
ans = exec_tweaks(old_tweaks_file)
|
||||
ans = make_unicode(ans)
|
||||
|
Loading…
x
Reference in New Issue
Block a user