@@ -112,10 +112,11 @@ private bool AskAgreeUpdate(UpdateData data)
112112 public bool ShouldDownloadUpdate ( UpdateData update_data , string current_file_path , bool no_ask )
113113 {
114114 //todo : version compare
115+ if ( ! File . Exists ( current_file_path ) ) { return true ; }
115116
116117 var current_file_hash = MD5HashFile ( current_file_path ) . ToLower ( ) ;
117118
118- return ( ( ! File . Exists ( current_file_path ) || current_file_hash != update_data . latestHash ) && AskAgreeUpdate ( update_data ) ) ;
119+ return ( current_file_hash != update_data . latestHash ) && AskAgreeUpdate ( update_data ) ;
119120 }
120121
121122 internal bool InternalUpdate ( string plugin_guid , bool no_ask )
@@ -144,7 +145,7 @@ internal bool InternalUpdate(string plugin_guid, bool no_ask)
144145 }
145146 catch ( Exception e )
146147 {
147- IO . CurrentIO . WriteColor ( string . Format ( LANG_UPDATE_ERROR , e . TargetSite . Name , e . Message ) , ConsoleColor . Red ) ;
148+ IO . CurrentIO . WriteColor ( string . Format ( LANG_UPDATE_ERROR , e . TargetSite . Name , e . Message ) , ConsoleColor . Yellow ) ;
148149 }
149150
150151 return false ;
@@ -211,6 +212,20 @@ private bool Search(string keyword)
211212 return false ;
212213 }
213214
215+ internal bool InstallByKeyword ( string keyword , bool requireRestart = true )
216+ {
217+ if ( Serializer < UpdateData [ ] > ( $ "http://sync.mcbaka.com/api/Update/search/{ keyword } ") is UpdateData [ ] datas )
218+ {
219+ if ( datas . Length == 0 || InternalUpdate ( datas [ 0 ] . guid , true ) )
220+ {
221+ if ( requireRestart ) RequireRestart ( LANG_INSTALL_DONE ) ;
222+ return true ;
223+ }
224+ else return false ;
225+ }
226+ return false ;
227+ }
228+
214229 private bool Install ( string guid )
215230 {
216231 if ( InternalUpdate ( guid , true ) )
@@ -220,16 +235,7 @@ private bool Install(string guid)
220235 }
221236 else
222237 {
223- if ( Serializer < UpdateData [ ] > ( $ "http://sync.mcbaka.com/api/Update/search/{ guid } ") is UpdateData [ ] datas )
224- {
225- if ( datas . Length == 0 || InternalUpdate ( datas [ 0 ] . guid , true ) )
226- {
227- RequireRestart ( LANG_INSTALL_DONE ) ;
228- return true ;
229- }
230- else return false ;
231- }
232- return false ;
238+ return InstallByKeyword ( guid ) ;
233239 }
234240 }
235241
@@ -443,4 +449,4 @@ private bool DownloadSingleFile(string dlUrl, string path, string name)
443449 }
444450 }
445451 }
446- }
452+ }
0 commit comments