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)
50
50
binary_path
51
51
end
52
52
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
+
53
60
def binary_path
54
61
dest_parent_dir = get_available_dirs
55
62
binary_path = File . join ( dest_parent_dir , "BrowserStackLocal#{ ".exe" if @windows } " )
63
+
56
64
if File . exists? binary_path
57
65
binary_path
58
66
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
60
82
end
61
83
end
62
84
You can’t perform that action at this time.
0 commit comments