summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2020-12-27 15:08:50 +0200
committerLars Wirzenius <liw@liw.fi>2020-12-27 15:08:50 +0200
commit619b0471182daf42615558a4449b3156541944f8 (patch)
tree72cd3cd0a84a4e07e4da3af44764cc39fd5ae356
parentbbde1bfd90edaa49463d7c3950ddcaa834e9ce02 (diff)
downloadobnam2-619b0471182daf42615558a4449b3156541944f8.tar.gz
refactor: rename Generation to NascentGeneration
New name is more descriptive.
-rw-r--r--src/cmd/backup.rs4
-rw-r--r--src/cmd/restore.rs8
-rw-r--r--src/generation.rs8
3 files changed, 10 insertions, 10 deletions
diff --git a/src/cmd/backup.rs b/src/cmd/backup.rs
index 2a294f5..c9b7fc5 100644
--- a/src/cmd/backup.rs
+++ b/src/cmd/backup.rs
@@ -1,6 +1,6 @@
use crate::client::{BackupClient, ClientConfig};
use crate::fsiter::FsIterator;
-use crate::generation::Generation;
+use crate::generation::NascentGeneration;
use indicatif::{ProgressBar, ProgressStyle};
use log::info;
use tempfile::NamedTempFile;
@@ -22,7 +22,7 @@ pub fn backup(config: &ClientConfig, buffer_size: usize) -> anyhow::Result<()> {
// Create the SQLite database using the named temporary file.
// The fetching is in its own block so that the file handles
// get closed and data flushed to disk.
- let mut gen = Generation::create(&dbname)?;
+ let mut gen = NascentGeneration::create(&dbname)?;
let progress = create_progress_bar(GUESS_FILE_COUNT, true);
progress.enable_steady_tick(100);
gen.insert_iter(FsIterator::new(&config.root).map(|entry| {
diff --git a/src/cmd/restore.rs b/src/cmd/restore.rs
index da654fd..dd7ed41 100644
--- a/src/cmd/restore.rs
+++ b/src/cmd/restore.rs
@@ -1,7 +1,7 @@
use crate::client::BackupClient;
use crate::client::ClientConfig;
use crate::fsentry::{FilesystemEntry, FilesystemKind};
-use crate::generation::Generation;
+use crate::generation::NascentGeneration;
use indicatif::{ProgressBar, ProgressStyle};
use libc::{fchmod, futimens, timespec};
use log::{debug, error, info};
@@ -37,7 +37,7 @@ pub fn restore(config: &ClientConfig, gen_id: &str, to: &Path) -> anyhow::Result
}
info!("downloaded generation to {}", dbname.display());
- let gen = Generation::open(&dbname)?;
+ let gen = NascentGeneration::open(&dbname)?;
info!("restore file count: {}", gen.file_count());
let progress = create_progress_bar(gen.file_count(), true);
for (fileid, entry) in gen.files()? {
@@ -74,7 +74,7 @@ struct Opt {
fn restore_generation(
client: &BackupClient,
- gen: &Generation,
+ gen: &NascentGeneration,
fileid: u64,
entry: &FilesystemEntry,
to: &Path,
@@ -123,7 +123,7 @@ fn restored_path(entry: &FilesystemEntry, to: &Path) -> anyhow::Result<PathBuf>
fn restore_regular(
client: &BackupClient,
- gen: &Generation,
+ gen: &NascentGeneration,
path: &Path,
fileid: u64,
entry: &FilesystemEntry,
diff --git a/src/generation.rs b/src/generation.rs
index 875221f..32b1e73 100644
--- a/src/generation.rs
+++ b/src/generation.rs
@@ -4,12 +4,12 @@ use rusqlite::{params, Connection, OpenFlags, Row, Transaction};
use std::path::Path;
/// A backup generation.
-pub struct Generation {
+pub struct NascentGeneration {
conn: Connection,
fileno: u64,
}
-impl Generation {
+impl NascentGeneration {
pub fn create<P>(filename: P) -> anyhow::Result<Self>
where
P: AsRef<Path>,
@@ -136,14 +136,14 @@ fn find_max_fileno(conn: &Connection) -> anyhow::Result<u64> {
#[cfg(test)]
mod test {
- use super::Generation;
+ use super::NascentGeneration;
use tempfile::NamedTempFile;
#[test]
fn empty() {
let filename = NamedTempFile::new().unwrap().path().to_path_buf();
{
- let mut _gen = Generation::create(&filename).unwrap();
+ let mut _gen = NascentGeneration::create(&filename).unwrap();
// _gen is dropped here; the connection is close; the file
// should not be removed.
}