Skip to content

Commit 1019fc0

Browse files
committed
set_directory(): restore old path in case of error.
1 parent 2bef241 commit 1019fc0

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

‎language_tool/__init__.py‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -528,11 +528,16 @@ def get_lt_dir(base_dir):
528528
def set_directory(path=None):
529529
"""Set LanguageTool directory.
530530
"""
531+
old_path = get_directory()
531532
terminate_server()
532533
cache.clear()
533534
if path:
534535
cache["language_tool_dir"] = path
535-
get_jar_info()
536+
try:
537+
get_jar_info()
538+
except Error:
539+
cache["language_tool_dir"] = old_path
540+
raise
536541

537542

538543
def get_server_cmd(port=None):

0 commit comments

Comments
 (0)