1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
use std::time::{SystemTime, UNIX_EPOCH};
use serde::{Deserialize, Serialize};
use uuid::Uuid;
use crate::{config::Config, pathinfo::PathInfo, packages::Package, error::Result};
pub type BackupId = String;
#[derive(Debug, Serialize, Deserialize)]
pub struct Backup {
id: String,
timestamp: u64,
packages: Vec<Package>,
files: Vec<PathInfo>,
}
impl Backup {
pub fn create(config: &Config, packages: Vec<Package>) -> Result<Self> {
let mut files: Vec<PathInfo> = Vec::new();
for dir in &config.directories {
files.push(PathInfo::from_path(config, dir)?);
}
Ok(Self {
// UUID not really needed, maybe a shorter hash
id: Uuid::new_v4().to_string(),
timestamp: SystemTime::now()
.duration_since(UNIX_EPOCH)
.unwrap()
.as_secs(),
packages,
files,
})
}
}
struct BackupLocation {
id: BackupId,
rel_location: String,
}
type BackupList = Vec<BackupLocation>;
|