Skip to content

Commit 3adcad2

Browse files
committed
some backup cleanup
1 parent 4e65cf1 commit 3adcad2

7 files changed

Lines changed: 12 additions & 9 deletions

File tree

application/src/remote/backups.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use super::client::Client;
22
use crate::server::backup::adapters::BackupAdapter;
3+
use compact_str::ToCompactString;
34
use serde::{Deserialize, Serialize};
45
use serde_json::json;
56
use std::collections::BTreeMap;
@@ -14,7 +15,7 @@ pub struct RawServerBackupPart {
1415
#[derive(Debug, Default, ToSchema, Serialize)]
1516
pub struct RawServerBackup {
1617
pub checksum: String,
17-
pub checksum_type: String,
18+
pub checksum_type: compact_str::CompactString,
1819
pub size: u64,
1920
pub files: u64,
2021
pub successful: bool,
@@ -33,9 +34,9 @@ pub struct ResticBackupConfiguration {
3334

3435
impl ResticBackupConfiguration {
3536
#[inline]
36-
pub fn password(&self) -> Vec<String> {
37+
pub fn password(&self) -> Vec<compact_str::CompactString> {
3738
if let Some(password_file) = &self.password_file {
38-
vec!["--password-file".into(), password_file.clone()]
39+
vec!["--password-file".into(), password_file.to_compact_string()]
3940
} else {
4041
Vec::new()
4142
}

application/src/server/backup/adapters/btrfs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ impl BackupCreateExt for BtrfsBackup {
214214
generation.unwrap_or_default(),
215215
uuid.unwrap_or_default()
216216
),
217-
checksum_type: "btrfs-subvolume".to_string(),
217+
checksum_type: "btrfs-subvolume".into(),
218218
size: total_size,
219219
files: total_files,
220220
successful: true,

application/src/server/backup/adapters/ddup_bak.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ impl BackupCreateExt for DdupBakBackup {
378378

379379
Ok(RawServerBackup {
380380
checksum: format!("{}-{:x}", file.metadata().await?.len(), sha1.finalize()),
381-
checksum_type: "ddup-sha1".to_string(),
381+
checksum_type: "ddup-sha1".into(),
382382
size: total_size,
383383
files: total_files,
384384
successful: true,

application/src/server/backup/adapters/restic.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,7 @@ impl BackupCreateExt for ResticBackup {
534534

535535
Ok(RawServerBackup {
536536
checksum: snapshot_id.unwrap_or_else(|| "unknown".to_string()),
537-
checksum_type: "restic".to_string(),
537+
checksum_type: "restic".into(),
538538
size: total_bytes_processed,
539539
files: total_files_processed,
540540
successful: true,

application/src/server/backup/adapters/s3.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,12 +183,14 @@ impl BackupCreateExt for S3Backup {
183183

184184
sha1.update(&buffer[..bytes_read]);
185185
file.write_all(&buffer[..bytes_read]).await?;
186+
total.fetch_add(bytes_read as u64, Ordering::Relaxed);
186187
}
187188

188189
Ok::<_, anyhow::Error>(format!("{:x}", sha1.finalize()))
189190
};
190191

191192
let total_task = {
193+
let total = Arc::clone(&total);
192194
let server = server.clone();
193195
let ignore = ignore.clone();
194196

@@ -350,7 +352,7 @@ impl BackupCreateExt for S3Backup {
350352

351353
Ok(RawServerBackup {
352354
checksum,
353-
checksum_type: "sha1".to_string(),
355+
checksum_type: "sha1".into(),
354356
size,
355357
files: total_files,
356358
successful: true,

application/src/server/backup/adapters/wings.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ impl BackupCreateExt for WingsBackup {
268268

269269
Ok(RawServerBackup {
270270
checksum: format!("{:x}", checksum_writer.finalize()),
271-
checksum_type: "sha1".to_string(),
271+
checksum_type: "sha1".into(),
272272
size,
273273
files: total_files,
274274
successful: true,

application/src/server/backup/adapters/zfs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ impl BackupCreateExt for ZfsBackup {
201201

202202
Ok(RawServerBackup {
203203
checksum: dataset_name,
204-
checksum_type: "zfs-subvolume".to_string(),
204+
checksum_type: "zfs-subvolume".into(),
205205
size: total_size,
206206
files: total_files,
207207
successful: true,

0 commit comments

Comments
 (0)