You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: cli/src/models.rs
+39-22
Original file line number
Diff line number
Diff line change
@@ -146,7 +146,7 @@ impl Payload {
146
146
147
147
if !util::is_valid_extension_name(&extension_name){
148
148
returnErr(anyhow::anyhow!(
149
-
"invalid extension name detected {}",
149
+
"Invalid extension name detected: {}. It must begin with an alphabet, contain only alphanumeric characters or `_` and should be between 2 and 32 characters long.",
150
150
extension_name
151
151
));
152
152
}
@@ -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. It should be have the format `major.minor.patch`.");
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. It should be have the format `major.minor.patch`.");
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. It should be have the format `major.minor.patch`.");
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
}
@@ -264,7 +279,9 @@ impl ControlFileRef {
264
279
returnself.read_control_line_value(line);
265
280
}
266
281
}
267
-
Err(anyhow::anyhow!("default version is required"))
0 commit comments