src/backup/{fixed, dynamic}_index.rs: improve error messages

This commit is contained in:
Dietmar Maurer 2019-07-02 08:56:56 +02:00
parent 5c593a4d56
commit 877dd11133
2 changed files with 4 additions and 2 deletions

View File

@ -61,7 +61,8 @@ impl DynamicIndexReader {
pub fn open(path: &Path) -> Result<Self, Error> { pub fn open(path: &Path) -> Result<Self, Error> {
let file = std::fs::File::open(&path)?; let file = std::fs::File::open(&path)
.map_err(|err| format_err!("Unable to open dynamic index {:?} - {}", path, err))?;
if let Err(err) = nix::fcntl::flock(file.as_raw_fd(), nix::fcntl::FlockArg::LockSharedNonblock) { if let Err(err) = nix::fcntl::flock(file.as_raw_fd(), nix::fcntl::FlockArg::LockSharedNonblock) {
bail!("unable to get shared lock on {:?} - {}", path, err); bail!("unable to get shared lock on {:?} - {}", path, err);

View File

@ -60,7 +60,8 @@ impl FixedIndexReader {
let full_path = store.relative_path(path); let full_path = store.relative_path(path);
let mut file = File::open(&full_path)?; let mut file = File::open(&full_path)
.map_err(|err| format_err!("Unable to open fixed index {:?} - {}", full_path, err))?;
if let Err(err) = nix::fcntl::flock(file.as_raw_fd(), nix::fcntl::FlockArg::LockSharedNonblock) { if let Err(err) = nix::fcntl::flock(file.as_raw_fd(), nix::fcntl::FlockArg::LockSharedNonblock) {
bail!("unable to get shared lock on {:?} - {}", full_path, err); bail!("unable to get shared lock on {:?} - {}", full_path, err);