@@ -112,10 +112,11 @@ private bool AskAgreeUpdate(UpdateData data)
112
112
public bool ShouldDownloadUpdate ( UpdateData update_data , string current_file_path , bool no_ask )
113
113
{
114
114
//todo : version compare
115
+ if ( ! File . Exists ( current_file_path ) ) { return true ; }
115
116
116
117
var current_file_hash = MD5HashFile ( current_file_path ) . ToLower ( ) ;
117
118
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 ) ;
119
120
}
120
121
121
122
internal bool InternalUpdate ( string plugin_guid , bool no_ask )
@@ -144,7 +145,7 @@ internal bool InternalUpdate(string plugin_guid, bool no_ask)
144
145
}
145
146
catch ( Exception e )
146
147
{
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 ) ;
148
149
}
149
150
150
151
return false ;
@@ -211,6 +212,20 @@ private bool Search(string keyword)
211
212
return false ;
212
213
}
213
214
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
+
214
229
private bool Install ( string guid )
215
230
{
216
231
if ( InternalUpdate ( guid , true ) )
@@ -220,16 +235,7 @@ private bool Install(string guid)
220
235
}
221
236
else
222
237
{
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 ) ;
233
239
}
234
240
}
235
241
@@ -443,4 +449,4 @@ private bool DownloadSingleFile(string dlUrl, string path, string name)
443
449
}
444
450
}
445
451
}
446
- }
452
+ }
0 commit comments