@@ -54,6 +54,8 @@ public static void RequestCompilation(string assemblyName = null)
5454 }
5555
5656 var allScripts = editorCompilation . Get ( "allScripts" ) as Dictionary < string , string > ;
57+ if ( allScripts == null ) return ;
58+
5759 var assemblyFilename = assemblyName + ".dll" ;
5860 var path = allScripts . FirstOrDefault ( x => x . Value == assemblyFilename ) . Key ;
5961 if ( string . IsNullOrEmpty ( path ) ) return ;
@@ -155,58 +157,64 @@ public static string DownloadFile(string url)
155157 {
156158 ServicePointManager . ServerCertificateValidationCallback = cb ;
157159
158- Logger . LogInfo ( "Download {0} (alternative)" , url ) ;
159-
160160 // NOTE: In .Net Framework 3.5, TSL1.2 is not supported.
161161 // So, download the file on command line instead.
162- switch ( Application . platform )
163- {
164- case RuntimePlatform . WindowsEditor :
165- ExecuteCommand ( "PowerShell.exe" , string . Format ( "curl -O {0} {1}" , downloadPath , url ) ) ;
166- break ;
167- case RuntimePlatform . OSXEditor :
168- ExecuteCommand ( "curl" , string . Format ( "-o {0} -L {1}" , downloadPath , url ) ) ;
169- break ;
170- case RuntimePlatform . LinuxEditor :
171- ExecuteCommand ( "wget" , string . Format ( "-O {0} {1}" , downloadPath , url ) ) ;
172- break ;
173- }
162+ Logger . LogInfo ( "Download {0} (alternative)" , url ) ;
163+ var args = GetDownloadCommand ( url , downloadPath , Application . platform ) ;
164+ ExecuteCommand ( args [ 0 ] , args [ 1 ] ) ;
174165 }
175166
176167 return downloadPath ;
177168 }
178169
179- /// <summary>
180- /// Extract archive file.
181- /// </summary>
182- /// <param name="archivePath">Archive file path</param>
183- /// <param name="extractTo">Extraction path</param>
170+ public static string [ ] GetDownloadCommand ( string url , string downloadPath , RuntimePlatform platform )
171+ {
172+ switch ( platform )
173+ {
174+ case RuntimePlatform . WindowsEditor :
175+ return new [ ] { "PowerShell.exe" , string . Format ( "curl -O {0} {1}" , downloadPath , url ) } ;
176+ case RuntimePlatform . OSXEditor :
177+ return new [ ] { "curl" , string . Format ( "-o {0} -L {1}" , downloadPath , url ) } ;
178+ case RuntimePlatform . LinuxEditor :
179+ return new [ ] { "wget" , string . Format ( "-O {0} {1}" , downloadPath , url ) } ;
180+
181+ default :
182+ throw new NotSupportedException ( $ "{ Application . platform } is not supported") ;
183+ }
184+ }
185+
186+ // Extract archive file.
184187 public static void ExtractArchive ( string archivePath , string extractTo )
185188 {
186189 Logger . LogInfo ( "Extract archive {0} to {1}" , archivePath , extractTo ) ;
187- var contentsPath = EditorApplication . applicationContentsPath ;
188- var args = string . Format ( "x {0} -o{1}" , archivePath , extractTo ) ;
189-
190- Directory . CreateDirectory ( Path . GetDirectoryName ( extractTo ) ) ;
190+ var args = GetExtractArchiveCommand ( archivePath , extractTo , Application . platform ) ;
191+ ExecuteCommand ( args [ 0 ] , args [ 1 ] ) ;
192+ }
191193
192- switch ( Application . platform )
194+ public static string [ ] GetExtractArchiveCommand ( string archivePath , string extractTo , RuntimePlatform platform )
195+ {
196+ var contentsPath = EditorApplication . applicationContentsPath ;
197+ switch ( platform )
193198 {
194199 case RuntimePlatform . WindowsEditor :
195- ExecuteCommand ( PathCombine ( contentsPath , "Tools" , "7z.exe" ) , args ) ;
196- break ;
200+ Directory . CreateDirectory ( Path . GetDirectoryName ( extractTo ) ) ;
201+ return new [ ] { PathCombine ( contentsPath , "Tools" , "7z.exe" ) , string . Format ( "x {0} -o{1}" , archivePath , extractTo ) } ;
197202 case RuntimePlatform . OSXEditor :
198203 case RuntimePlatform . LinuxEditor :
199204 if ( archivePath . EndsWith ( "tar.gz" ) )
200205 {
201- // 7za doesn't preserve permission but tar does
202206 Directory . CreateDirectory ( extractTo ) ;
203- ExecuteCommand ( "tar" , string . Format ( "-pzxf {0} -C {1}" , archivePath , extractTo ) ) ;
207+ return new [ ] { "tar" , string . Format ( "-pzxf {0} -C {1}" , archivePath , extractTo ) } ;
204208 }
205209 else
206- ExecuteCommand ( PathCombine ( contentsPath , "Tools" , "7za" ) , args ) ;
207-
208- break ;
210+ {
211+ Directory . CreateDirectory ( Path . GetDirectoryName ( extractTo ) ) ;
212+ return new [ ] { PathCombine ( contentsPath , "Tools" , "7za" ) , string . Format ( "x {0} -o{1}" , archivePath , extractTo ) } ;
213+ }
214+ default :
215+ throw new NotSupportedException ( $ "{ Application . platform } is not supported") ;
209216 }
217+
210218 }
211219
212220 /// <summary>
0 commit comments