report filename when unable to read data

This commit is contained in:
Damien Elmes 2020-04-30 08:02:08 +10:00
parent 18a6218a77
commit a4d33dbdb0
2 changed files with 8 additions and 3 deletions

View File

@ -151,7 +151,10 @@ where
}
// add entry to the list
let sha1 = Some(sha1_of_file(&dentry.path())?);
let data = sha1_of_file(&dentry.path()).map_err(|e| AnkiError::IOError {
info: format!("unable to read {}: {}", fname, e),
})?;
let sha1 = Some(data);
added_or_changed.push(FilesystemEntry {
fname: fname.to_string(),
sha1,

View File

@ -1,7 +1,7 @@
// Copyright: Ankitects Pty Ltd and contributors
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
use crate::err::Result;
use crate::err::{AnkiError, Result};
use crate::log::{debug, Logger};
use lazy_static::lazy_static;
use regex::Regex;
@ -402,7 +402,9 @@ pub(super) fn data_for_file(media_folder: &Path, fname: &str) -> Result<Option<V
if e.kind() == io::ErrorKind::NotFound {
return Ok(None);
} else {
return Err(e.into());
return Err(AnkiError::IOError {
info: format!("unable to read {}: {}", fname, e),
});
}
}
};