diff options
author | Lars Wirzenius <liw@liw.fi> | 2021-06-20 10:37:45 +0300 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2021-07-05 16:26:14 +0300 |
commit | e6147a3b7b58b151fb7ad9b1f748e0a666f271de (patch) | |
tree | c58ee06b5f327a569cc7e464f813eaad9dfc6d5d /src/generation.rs | |
parent | 79c71be291b3cf1fad52e2fbdc28be12d3e11311 (diff) | |
download | obnam2-e6147a3b7b58b151fb7ad9b1f748e0a666f271de.tar.gz |
refactor: code to run backups to have less repetition
This should make it easier to introduce async, later.
Diffstat (limited to 'src/generation.rs')
-rw-r--r-- | src/generation.rs | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/generation.rs b/src/generation.rs index 85af1f5..e48dce2 100644 --- a/src/generation.rs +++ b/src/generation.rs @@ -32,6 +32,9 @@ pub enum NascentError { #[error("SQL commit error: {0}")] Commit(rusqlite::Error), + + #[error("Failed to create temporary file: {0}")] + TempFile(#[from] std::io::Error), } pub type NascentResult<T> = Result<T, NascentError>; @@ -221,6 +224,7 @@ mod sql { use crate::backup_reason::Reason; use crate::chunkid::ChunkId; use crate::fsentry::FilesystemEntry; + use log::debug; use rusqlite::{params, Connection, OpenFlags, Row, Statement, Transaction}; use std::os::unix::ffi::OsStrExt; use std::path::Path; @@ -403,12 +407,16 @@ mod sql { stmt.query_map(params![path_into_blob(filename)], |row| row_to_entry(row))?; match iter.next() { None => Ok(None), - Some(Err(e)) => Err(e.into()), + Some(Err(e)) => { + debug!("database lookup error: {}", e); + Err(e.into()) + } Some(Ok((fileno, json, reason))) => { let entry = serde_json::from_str(&json)?; if iter.next() == None { Ok(Some((fileno, entry, reason))) } else { + debug!("too many files in file lookup"); Err(LocalGenerationError::TooManyFiles(filename.to_path_buf())) } } |