fixup: allow 'so' validation to fail, and just continue
This commit is contained in:
parent
aa0c287fe5
commit
1b6e7edb6b
1 changed files with 9 additions and 7 deletions
|
|
@ -61,22 +61,24 @@ impl Magnet {
|
|||
}
|
||||
"tr" => trackers.push(value.into()),
|
||||
"so" => {
|
||||
// Process 'so' values, but silently ignore any which fail parsing
|
||||
for file_desc in value.split(',') {
|
||||
if file_desc.is_empty() {
|
||||
continue;
|
||||
}
|
||||
// Handling ranges of file indices
|
||||
if let Some((start, end)) = file_desc.split_once('-') {
|
||||
let start_idx: usize = start.parse()?;
|
||||
let end_idx: usize = end.parse()?;
|
||||
if start_idx >= end_idx {
|
||||
anyhow::bail!("range start must be less than range end");
|
||||
let maybe_start_idx: Result<usize, _> = start.parse();
|
||||
let maybe_end_idx: Result<usize, _> = end.parse();
|
||||
if let (Ok(start_idx), Ok(end_idx)) = (maybe_start_idx, maybe_end_idx) {
|
||||
files.extend(start_idx..=end_idx);
|
||||
}
|
||||
files.extend(start_idx..=end_idx);
|
||||
} else {
|
||||
// Handling single file index
|
||||
let idx: usize = file_desc.parse()?;
|
||||
files.push(idx);
|
||||
let idx = file_desc.parse();
|
||||
if let Ok(idx) = idx {
|
||||
files.push(idx);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue