Remove BookSheet and make it normal Sheet
Simplifies code a lot
This commit is contained in:
@@ -85,7 +85,7 @@ impl FileValidationResult {
|
||||
fn validate_sheet_files(sheets: Vec<Sheet>, dir: impl AsRef<Path>) -> FileValidationResult {
|
||||
let (validated_sheets, mut invalidated_sheets): (Vec<_>, Vec<_>) = sheets
|
||||
.into_iter()
|
||||
.partition(|sheet| sheet.validate_own_path().unwrap_or(false));
|
||||
.partition(|sheet| sheet.pdf.validate_own_path().unwrap_or(false));
|
||||
|
||||
let mut updated_sheets = Vec::new();
|
||||
let mut unassigned_files = Vec::new();
|
||||
@@ -95,15 +95,15 @@ fn validate_sheet_files(sheets: Vec<Sheet>, dir: impl AsRef<Path>) -> FileValida
|
||||
if let Some((i, _)) = invalidated_sheets
|
||||
.iter()
|
||||
.enumerate()
|
||||
.find(|(_, sheet)| sheet.validate_path(&pdf_file).unwrap_or(false))
|
||||
.find(|(_, sheet)| sheet.pdf.validate_path(&pdf_file).unwrap_or(false))
|
||||
{
|
||||
let mut sheet = invalidated_sheets.remove(i);
|
||||
let new_pdf = Pdf::try_from(pdf_file).unwrap();
|
||||
sheet.update_pdf_file(new_pdf);
|
||||
sheet.pdf = new_pdf;
|
||||
updated_sheets.push(sheet);
|
||||
} else if !validated_sheets
|
||||
.iter()
|
||||
.any(|sheet| sheet.pdf_path_equal(&pdf_file))
|
||||
.any(|sheet| sheet.pdf.path == pdf_file)
|
||||
{
|
||||
unassigned_files.push(pdf_file);
|
||||
}
|
||||
|
Reference in New Issue
Block a user