Skip to content

Commit acb6dd8

Browse files
committed
Avoid scanning config dir that does not exist
Since #354 it was possible that we checked for the presence of an assembly jar in the config directory before ever creating that dir ourselves. This should fix #363.
1 parent f3fd702 commit acb6dd8

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

ensime_shared/launcher.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,8 @@ def __init__(self, config, base_dir):
205205
self.toolsjar = os.path.join(config['java-home'], 'lib', 'tools.jar')
206206

207207
def isinstalled(self):
208+
if not os.path.exists(self.base_dir):
209+
return False
208210
scala_minor = self.config['scala-version'][:4]
209211
for fname in os.listdir(self.base_dir):
210212
if fnmatch(fname, "ensime_" + scala_minor + "*-assembly.jar"):

test/test_launcher.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ def test_isinstalled_if_jar_file_present(self, strategy):
4141
self.assemblyjar(strategy)
4242
assert strategy.isinstalled()
4343

44+
def test_isinstalled_when_base_dir_does_not_exist(self, tmpdir):
45+
bogus = tmpdir / 'nonexisting'
46+
strategy = AssemblyJar(config('test-bootstrap.conf'), base_dir=bogus.strpath)
47+
assert not strategy.isinstalled()
48+
4449
def test_launch_constructs_classpath(self, strategy, assemblyjar):
4550
assert strategy.isinstalled()
4651
with patch.object(strategy, '_start_process', autospec=True) as start:

0 commit comments

Comments
 (0)