L
This commit is contained in:
commit
f1e5d370d3
9 changed files with 1970 additions and 0 deletions
2
.cargo/config.toml
Normal file
2
.cargo/config.toml
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
[registries.crates-io]
|
||||||
|
protocol = "sparse"
|
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
/target
|
1868
Cargo.lock
generated
Normal file
1868
Cargo.lock
generated
Normal file
File diff suppressed because it is too large
Load diff
15
Cargo.toml
Normal file
15
Cargo.toml
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
[package]
|
||||||
|
name = "upback"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
anyhow = "1.0.71"
|
||||||
|
clap = { version = "4.3.3", features = ["derive"] }
|
||||||
|
dirs = "5.0.1"
|
||||||
|
serde = { version = "1.0.164", features = ["derive"] }
|
||||||
|
serde_yaml = "0.9.21"
|
||||||
|
tokio = { version = "1.28.2", features = ["full"] }
|
||||||
|
twelf = { version = "0.11.0", features = ["json", "yaml", "toml", "dhall"] }
|
2
config.yml
Normal file
2
config.yml
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
directories:
|
||||||
|
/Users/michaelzhang/tmp/upback:
|
4
rustfmt.toml
Normal file
4
rustfmt.toml
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
max_width = 80
|
||||||
|
tab_spaces = 2
|
||||||
|
wrap_comments = true
|
||||||
|
fn_single_line = true
|
39
src/config.rs
Normal file
39
src/config.rs
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
use std::{collections::HashMap, path::PathBuf};
|
||||||
|
|
||||||
|
use twelf::config;
|
||||||
|
|
||||||
|
#[derive(Debug, Serialize)]
|
||||||
|
#[config]
|
||||||
|
pub struct Config {
|
||||||
|
#[serde(default)]
|
||||||
|
directories: HashMap<PathBuf, PathBackupConfig>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Serialize)]
|
||||||
|
#[config]
|
||||||
|
pub struct PathBackupConfig {
|
||||||
|
#[serde(default)]
|
||||||
|
update_check_strategy: Option<UpdateCheckStrategy>,
|
||||||
|
|
||||||
|
#[serde(default)]
|
||||||
|
subpaths: HashMap<PathBuf, PathBackupConfig>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Serialize)]
|
||||||
|
#[config]
|
||||||
|
pub struct DestinationConfig {
|
||||||
|
backend: DestinationBackend,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Default, Debug, Serialize, Deserialize)]
|
||||||
|
pub enum UpdateCheckStrategy {
|
||||||
|
/// Just check atime + file size
|
||||||
|
#[default]
|
||||||
|
AtimeFileSize,
|
||||||
|
|
||||||
|
/// Calculate a 128-bit checksum (slow)
|
||||||
|
Checksum,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
|
pub enum DestinationBackend {}
|
25
src/main.rs
Normal file
25
src/main.rs
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
pub mod config;
|
||||||
|
pub mod patterns;
|
||||||
|
|
||||||
|
#[macro_use]
|
||||||
|
extern crate serde;
|
||||||
|
|
||||||
|
use std::{fs::File, io::Read};
|
||||||
|
|
||||||
|
use anyhow::Result;
|
||||||
|
|
||||||
|
use crate::config::Config;
|
||||||
|
|
||||||
|
#[tokio::main]
|
||||||
|
async fn main() -> Result<()> {
|
||||||
|
println!("Hello, world!");
|
||||||
|
|
||||||
|
let config: Config = {
|
||||||
|
let file = File::open("config.yml")?;
|
||||||
|
serde_yaml::from_reader(file)?
|
||||||
|
};
|
||||||
|
|
||||||
|
println!("config: {config:?}");
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
14
src/patterns.rs
Normal file
14
src/patterns.rs
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
use std::path::PathBuf;
|
||||||
|
|
||||||
|
pub struct Pattern {
|
||||||
|
pub found_at: PathBuf,
|
||||||
|
pub kind: PatternKind,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub enum PatternKind {
|
||||||
|
/// Just a plain ol' file. Read + write
|
||||||
|
Regular,
|
||||||
|
|
||||||
|
/// Archives can probably be diffed granularly? Maybe above a certain file size
|
||||||
|
Archive,
|
||||||
|
}
|
Loading…
Reference in a new issue