From 3eaefd722311abd30f13bd25c8037fbe5ed02b7e Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Tue, 16 Feb 2021 12:22:57 +0200 Subject: refactor: use bytesize::MIB constant for clearer size --- Cargo.toml | 1 + src/client.rs | 3 ++- src/cmd/backup.rs | 3 ++- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index ed816b9..d36c450 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,6 +12,7 @@ repository = "https://gitlab.com/larswirzenius/obnam" [dependencies] anyhow = "1" bytes = "0.5" +bytesize = "1" chrono = "0.4" dirs = "3" indicatif = "0.15" diff --git a/src/client.rs b/src/client.rs index e4d9be8..a475ce9 100644 --- a/src/client.rs +++ b/src/client.rs @@ -8,6 +8,7 @@ use crate::fsentry::{FilesystemEntry, FilesystemKind}; use crate::generation::{FinishedGeneration, LocalGeneration, LocalGenerationError}; use crate::genlist::GenerationList; +use bytesize::MIB; use chrono::{DateTime, Local}; use log::{debug, error, info, trace}; use reqwest::blocking::Client; @@ -17,7 +18,7 @@ use std::fs::File; use std::io::prelude::*; use std::path::{Path, PathBuf}; -const DEFAULT_CHUNK_SIZE: usize = 1024 * 1024; +const DEFAULT_CHUNK_SIZE: usize = MIB as usize; const DEVNULL: &str = "/dev/null"; #[derive(Debug, Serialize, Deserialize, Clone)] diff --git a/src/cmd/backup.rs b/src/cmd/backup.rs index 16d3f69..3f2d7d4 100644 --- a/src/cmd/backup.rs +++ b/src/cmd/backup.rs @@ -4,12 +4,13 @@ use crate::client::{BackupClient, ClientConfig}; use crate::error::ObnamError; use crate::fsiter::FsIterator; use crate::generation::NascentGeneration; +use bytesize::MIB; use log::info; use std::path::{Path, PathBuf}; use std::time::SystemTime; use tempfile::NamedTempFile; -const SQLITE_CHUNK_SIZE: usize = 1024 * 1024; +const SQLITE_CHUNK_SIZE: usize = MIB as usize; pub fn backup(config: &ClientConfig) -> Result<(), ObnamError> { let runtime = SystemTime::now(); -- cgit v1.2.1