summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2021-02-16 10:24:04 +0000
committerLars Wirzenius <liw@liw.fi>2021-02-16 10:24:04 +0000
commit3220fb17fe56cd0373a0079f0847158c4b127c59 (patch)
treed3a6cad99edcefb27619cb57d24fd2a334c2d08b
parent8f3436023925afb21daab7db5f52204bb84fd37f (diff)
parent3eaefd722311abd30f13bd25c8037fbe5ed02b7e (diff)
downloadobnam2-3220fb17fe56cd0373a0079f0847158c4b127c59.tar.gz
Merge branch 'bytesize' into 'main'
refactor: use bytesize::MIB constant for clearer size See merge request larswirzenius/obnam!99
-rw-r--r--Cargo.toml1
-rw-r--r--src/client.rs3
-rw-r--r--src/cmd/backup.rs3
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();