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 serde::{Deserialize, Serialize};
use std::borrow::Borrow;
use std::fmt; use super::State;
/// Represents the changes relative to the previous backup /// Represents the changes relative to the previous backup
#[derive(Debug, Serialize, Deserialize, Clone)] #[derive(Debug, Serialize, Deserialize, Clone)]

View File

@ -1,6 +1,4 @@
use std::error::Error; use std::{error::Error, fmt, str::FromStr};
use std::fmt;
use std::str::FromStr;
use serde::{Deserialize, Serialize}; 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 chrono::Utc;
use serde::Deserialize; use serde::{Deserialize, Serialize};
use serde::Serialize;
use std::collections::HashMap; use super::{Manager, ManagerConfig};
use std::io;
use std::path::{Path, PathBuf};
/// Manages a collection of backup layers, allowing them to be utilized as a single object. /// Manages a collection of backup layers, allowing them to be utilized as a single object.
pub struct MetaManager<T> pub struct MetaManager<T>

View File

@ -1,20 +1,20 @@
mod config; mod config;
mod meta; mod meta;
pub use config::ManagerConfig; use std::{
pub use meta::MetaManager; 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 super::{Backup, BackupType, Delta, State};
use crate::other; use crate::other;
use chrono::SubsecRound; pub use config::ManagerConfig;
use chrono::Utc; pub use meta::MetaManager;
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};
/// Manages a single backup layer consisting of one or more chains of backups. /// Manages a single backup layer consisting of one or more chains of backups.
pub struct Manager<T> pub struct Manager<T>

View File

@ -4,23 +4,24 @@ pub mod manager;
mod path; mod path;
mod state; 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; use delta::Delta;
pub use manager::Manager; pub use manager::Manager;
pub use manager::ManagerConfig; pub use manager::ManagerConfig;
pub use manager::MetaManager; 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 path::PathExt;
use serde::{Deserialize, Serialize}; pub use state::State;
use std::collections::HashSet;
use std::fmt;
use std::fs::File;
use std::io;
use std::path::{Path, PathBuf};
const BYTE_SUFFIXES: [&str; 5] = ["B", "KiB", "MiB", "GiB", "TiB"]; 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 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 { pub struct ReadDirRecursive {
ignored: HashSet<OsString>, 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 serde::{Deserialize, Serialize};
use std::borrow::Borrow;
use std::collections::{HashMap, HashSet}; use crate::backup::Delta;
use std::ops::{Deref, DerefMut};
use std::path::{Path, PathBuf};
/// Struct that represents a current state for a backup. This struct acts as a smart pointer around /// Struct that represents a current state for a backup. This struct acts as a smart pointer around
/// a HashMap. /// 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::io;
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use chrono::{TimeZone, Utc};
use clap::{Args, Subcommand};
use crate::{backup::Backup, other};
#[derive(Subcommand)] #[derive(Subcommand)]
pub enum BackupCommands { pub enum BackupCommands {
/// List all tracked backups /// List all tracked backups

View File

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

View File

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

View File

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

View File

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