File tree Expand file tree Collapse file tree 1 file changed +23
-1
lines changed
Expand file tree Collapse file tree 1 file changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -50,13 +50,35 @@ def download(dest_parent_dir)
5050 binary_path
5151 end
5252
53+ def verify_binary ( binary_path )
54+ binary_response = IO . popen ( binary_path + " --version" ) . readline
55+ binary_response =~ /BrowserStack Local version \d +\. \d +/
56+ rescue Exception => e
57+ false
58+ end
59+
5360 def binary_path
5461 dest_parent_dir = get_available_dirs
5562 binary_path = File . join ( dest_parent_dir , "BrowserStackLocal#{ ".exe" if @windows } " )
63+
5664 if File . exists? binary_path
5765 binary_path
5866 else
59- download ( dest_parent_dir )
67+ binary_path = download ( dest_parent_dir )
68+ end
69+
70+ valid_binary = verify_binary ( binary_path )
71+
72+ if valid_binary
73+ binary_path
74+ else
75+ binary_path = download ( dest_parent_dir )
76+ valid_binary = verify_binary ( binary_path )
77+ if valid_binary
78+ binary_path
79+ else
80+ raise BrowserStack ::LocalException . new ( 'BrowserStack Local binary is corrupt' )
81+ end
6082 end
6183 end
6284
You can’t perform that action at this time.
0 commit comments