@@ -166,31 +166,46 @@ impl Payload {
166
166
match & parts[ ..] {
167
167
[ file_ext_name, ver] => {
168
168
// Make sure the file's extension name matches the control file
169
- if file_ext_name == & extension_name && util:: is_valid_version ( ver) {
170
- let ifile = InstallFile {
171
- filename : file_name. to_string ( ) ,
172
- version : ver. to_string ( ) ,
173
- body : fs:: read_to_string ( & path)
174
- . context ( format ! ( "Failed to read file {}" , & file_name) ) ?,
175
- } ;
176
- install_files. push ( ifile) ;
169
+ if file_ext_name != & extension_name {
170
+ println ! ( "Warning: file `{file_name}` will be skipped because its extension name(`{file_ext_name}`) doesn't match `{extension_name}`" ) ;
171
+ continue ;
172
+ }
173
+ if !util:: is_valid_version ( ver) {
174
+ println ! ( "Warning: file `{file_name}` will be skipped because its version (`{ver}`) is invalid" ) ;
175
+ continue ;
177
176
}
177
+
178
+ let ifile = InstallFile {
179
+ filename : file_name. to_string ( ) ,
180
+ version : ver. to_string ( ) ,
181
+ body : fs:: read_to_string ( & path)
182
+ . context ( format ! ( "Failed to read file {}" , & file_name) ) ?,
183
+ } ;
184
+ install_files. push ( ifile) ;
178
185
}
179
186
[ file_ext_name, from_ver, to_ver] => {
180
187
// Make sure the file's extension name matches the control file
181
- if file_ext_name == & extension_name
182
- && util:: is_valid_version ( from_ver)
183
- && util:: is_valid_version ( to_ver)
184
- {
185
- let ufile = UpgradeFile {
186
- filename : file_name. to_string ( ) ,
187
- from_version : from_ver. to_string ( ) ,
188
- to_version : to_ver. to_string ( ) ,
189
- body : fs:: read_to_string ( & path)
190
- . context ( format ! ( "Failed to read file {}" , & file_name) ) ?,
191
- } ;
192
- upgrade_files. push ( ufile) ;
188
+ if file_ext_name != & extension_name {
189
+ println ! ( "Warning: file `{file_name}` will be skipped because its extension name(`{file_ext_name}`) doesn't match `{extension_name}`" ) ;
190
+ continue ;
193
191
}
192
+ if !util:: is_valid_version ( from_ver) {
193
+ println ! ( "Warning: file `{file_name}` will be skipped because its from version(`{from_ver}`) is invalid." ) ;
194
+ continue ;
195
+ }
196
+ if !util:: is_valid_version ( to_ver) {
197
+ println ! ( "Warning: file `{file_name}` will be skipped because its from version(`{to_ver}`) is invalid." ) ;
198
+ continue ;
199
+ }
200
+
201
+ let ufile = UpgradeFile {
202
+ filename : file_name. to_string ( ) ,
203
+ from_version : from_ver. to_string ( ) ,
204
+ to_version : to_ver. to_string ( ) ,
205
+ body : fs:: read_to_string ( & path)
206
+ . context ( format ! ( "Failed to read file {}" , & file_name) ) ?,
207
+ } ;
208
+ upgrade_files. push ( ufile) ;
194
209
}
195
210
_ => ( ) ,
196
211
}
0 commit comments