refactor: reorder imports
ci/woodpecker/push/lint Pipeline was successful Details
ci/woodpecker/push/clippy Pipeline was successful Details
ci/woodpecker/push/build Pipeline was successful Details

main
Jef Roosens 2023-08-11 23:24:14 +02:00
parent db3bba5a42
commit a51ff3937d
Signed by: Jef Roosens
GPG Key ID: B75D4F293C7052DB
12 changed files with 106 additions and 91 deletions

View File

@ -1,7 +1,8 @@
use super::State;
use std::{borrow::Borrow, fmt};
use serde::{Deserialize, Serialize};
use std::borrow::Borrow;
use std::fmt;
use super::State;
/// Represents the changes relative to the previous backup
#[derive(Debug, Serialize, Deserialize, Clone)]

View File

@ -1,6 +1,4 @@
use std::error::Error;
use std::fmt;
use std::str::FromStr;
use std::{error::Error, fmt, str::FromStr};
use serde::{Deserialize, Serialize};

View File

@ -1,10 +1,13 @@
use super::{Manager, ManagerConfig};
use std::{
collections::HashMap,
io,
path::{Path, PathBuf},
};
use chrono::Utc;
use serde::Deserialize;
use serde::Serialize;
use std::collections::HashMap;
use std::io;
use std::path::{Path, PathBuf};
use serde::{Deserialize, Serialize};
use super::{Manager, ManagerConfig};
/// Manages a collection of backup layers, allowing them to be utilized as a single object.
pub struct MetaManager<T>

View File

@ -1,20 +1,20 @@
mod config;
mod meta;
pub use config::ManagerConfig;
pub use meta::MetaManager;
use std::{
fs::{File, OpenOptions},
io,
path::{Path, PathBuf},
};
use chrono::{SubsecRound, Utc};
use flate2::{write::GzEncoder, Compression};
use serde::{Deserialize, Serialize};
use super::{Backup, BackupType, Delta, State};
use crate::other;
use chrono::SubsecRound;
use chrono::Utc;
use flate2::write::GzEncoder;
use flate2::Compression;
use serde::Deserialize;
use serde::Serialize;
use std::fs::{File, OpenOptions};
use std::io;
use std::path::{Path, PathBuf};
pub use config::ManagerConfig;
pub use meta::MetaManager;
/// Manages a single backup layer consisting of one or more chains of backups.
pub struct Manager<T>

View File

@ -4,23 +4,24 @@ pub mod manager;
mod path;
mod state;
use std::{
collections::HashSet,
fmt,
fs::File,
io,
path::{Path, PathBuf},
};
use chrono::Utc;
use flate2::{read::GzDecoder, write::GzEncoder, Compression};
use serde::{Deserialize, Serialize};
use delta::Delta;
pub use manager::Manager;
pub use manager::ManagerConfig;
pub use manager::MetaManager;
pub use state::State;
use chrono::Utc;
use flate2::read::GzDecoder;
use flate2::write::GzEncoder;
use flate2::Compression;
use path::PathExt;
use serde::{Deserialize, Serialize};
use std::collections::HashSet;
use std::fmt;
use std::fs::File;
use std::io;
use std::path::{Path, PathBuf};
pub use state::State;
const BYTE_SUFFIXES: [&str; 5] = ["B", "KiB", "MiB", "GiB", "TiB"];

View File

@ -1,9 +1,12 @@
use std::{
collections::HashSet,
ffi::OsString,
fs::{self, DirEntry},
io,
path::{Path, PathBuf},
};
use chrono::{Local, Utc};
use std::collections::HashSet;
use std::ffi::OsString;
use std::fs::DirEntry;
use std::path::{Path, PathBuf};
use std::{fs, io};
pub struct ReadDirRecursive {
ignored: HashSet<OsString>,

View File

@ -1,9 +1,13 @@
use crate::backup::Delta;
use std::{
borrow::Borrow,
collections::{HashMap, HashSet},
ops::{Deref, DerefMut},
path::{Path, PathBuf},
};
use serde::{Deserialize, Serialize};
use std::borrow::Borrow;
use std::collections::{HashMap, HashSet};
use std::ops::{Deref, DerefMut};
use std::path::{Path, PathBuf};
use crate::backup::Delta;
/// Struct that represents a current state for a backup. This struct acts as a smart pointer around
/// a HashMap.

View File

@ -1,10 +1,11 @@
use crate::backup::Backup;
use crate::other;
use chrono::{TimeZone, Utc};
use clap::{Args, Subcommand};
use std::io;
use std::path::{Path, PathBuf};
use chrono::{TimeZone, Utc};
use clap::{Args, Subcommand};
use crate::{backup::Backup, other};
#[derive(Subcommand)]
pub enum BackupCommands {
/// List all tracked backups

View File

@ -2,28 +2,33 @@ mod backup;
mod config;
mod run;
pub use crate::backup::MetaManager;
pub use crate::server::Metadata;
pub use backup::{BackupArgs, BackupCommands};
pub use run::RunCli;
use std::path::PathBuf;
use crate::backup::ManagerConfig;
use crate::server::ServerType;
use clap::{Args, Parser, Subcommand};
pub use config::Config;
use figment::{
providers::{Env, Format, Serialized, Toml},
Figment,
};
use serde::{Deserialize, Serialize};
use std::path::PathBuf;
#[derive(Subcommand)]
pub enum Commands {
/// Run the server
Run(RunCli),
/// Interact with the backup system without starting a server
Backup(BackupArgs),
use crate::{backup::ManagerConfig, server::ServerType};
use backup::BackupArgs;
use config::Config;
use run::RunCli;
#[derive(Parser, Serialize)]
#[command(author, version, about, long_about = None)]
pub struct Cli {
#[command(subcommand)]
#[serde(skip)]
pub command: Commands,
/// Path to a TOML configuration file
#[arg(long = "config-file", global = true)]
pub config_file: Option<PathBuf>,
#[command(flatten)]
pub args: CliArgs,
}
#[derive(Args, Serialize, Deserialize, Clone)]
@ -60,19 +65,12 @@ pub struct CliArgs {
pub server_version: Option<String>,
}
#[derive(Parser, Serialize)]
#[command(author, version, about, long_about = None)]
pub struct Cli {
#[command(subcommand)]
#[serde(skip)]
pub command: Commands,
/// Path to a TOML configuration file
#[arg(long = "config-file", global = true)]
pub config_file: Option<PathBuf>,
#[command(flatten)]
pub args: CliArgs,
#[derive(Subcommand)]
pub enum Commands {
/// Run the server
Run(RunCli),
/// Interact with the backup system without starting a server
Backup(BackupArgs),
}
impl Cli {

View File

@ -1,15 +1,16 @@
mod config;
use crate::server;
use crate::signals;
use crate::stdin;
use clap::Args;
use config::Config;
use std::path::PathBuf;
use std::sync::{Arc, Mutex};
use std::{
path::PathBuf,
sync::{Arc, Mutex},
};
use clap::Args;
use serde::{Deserialize, Serialize};
use crate::{server, signals, stdin};
use config::Config;
#[derive(Args)]
pub struct RunCli {
#[command(flatten)]

View File

@ -1,10 +1,13 @@
use std::io;
use std::sync::atomic::AtomicBool;
use std::sync::{Arc, Mutex};
use std::{
io,
sync::{atomic::AtomicBool, Arc, Mutex},
};
use signal_hook::consts::TERM_SIGNALS;
use signal_hook::flag;
use signal_hook::iterator::{Signals, SignalsInfo};
use signal_hook::{
consts::TERM_SIGNALS,
flag,
iterator::{Signals, SignalsInfo},
};
use crate::server;

View File

@ -1,5 +1,7 @@
use std::io;
use std::sync::{Arc, Mutex};
use std::{
io,
sync::{Arc, Mutex},
};
use crate::server;