Skip to content

Commit

Permalink
changed project structure
Browse files Browse the repository at this point in the history
  • Loading branch information
Fran314 committed Aug 18, 2022
1 parent ecd3610 commit a7da2a3
Show file tree
Hide file tree
Showing 48 changed files with 981 additions and 839 deletions.
106 changes: 74 additions & 32 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 2 additions & 25 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,25 +1,2 @@
[package]
name = "bbup-rust"
version = "0.1.1"
edition = "2021"
repository = "https://github.com/Fran314/bbup-rust"

[dependencies]
sha2 = "0.10.2" # hashtree
base64ct = { version = "1.5.0", features = ["alloc"] } # hashtree
regex = "1.5" # hashtree
serde = { version = "1.0", features = ["derive"] } # fs & comunication
bincode = "1.3.3"
toml = "0.5"
# serde_json = "1.0" # fs & comunication
# serde_yaml = "0.8" # fs & comunication
clap = { version = "3.2.5", features = ["derive"] } # server & client (cli)
dirs = "4.0.0" # server & client (home directory)
tokio = { version = "1", features = ["full"] } # server (multithread)
rand = { version = "0.8.5", features = ["small_rng"] } # random
anyhow = "1.0"
thiserror = "1.0"
indicatif = "0.16.2" # progress bar
filetime = "0.2" # to set file times on different OSs
colored = "2" # For colored strings in output (it's Rust after all!)
chrono = "0.4" # For timestamp formatting
[workspace]
members = ["bbup", "lib/*"]
20 changes: 20 additions & 0 deletions bbup/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[package]
name = "bbup"
version = "0.1.1"
edition = "2021"

[dependencies]
serde = { version = "1.0", features = ["derive"] }
anyhow = "1.0"
thiserror = "1.0"
tokio = { version = "1", features = ["full"] }
bincode = "1.3"
indicatif = "0.16"
clap = { version = "3.2", features = ["derive"] }

abst_fs = { path = "../lib/abst_fs" }
ssh_tunnel = { path = "../lib/ssh_tunnel" }
input = { path = "../lib/input" }
ior = { path = "../lib/ior" }
hasher = { path = "../lib/hasher" }
fs_vcs = { path = "../lib/fs_vcs" }
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::sync::Arc;

use bbup_rust::fs;
use abst_fs as fs;

mod smodel;
use smodel::*;
Expand All @@ -13,6 +13,7 @@ use tokio::{net::TcpListener, sync::Mutex};

#[derive(Subcommand, Debug, PartialEq)]
enum SubCommand {
#[clap(version)]
/// Run the daemon
Run {
/// Increase verbosity
Expand All @@ -23,11 +24,13 @@ enum SubCommand {
#[clap(short, long)]
progress: bool,
},
#[clap(version)]
/// Initialize bbup client
Setup,
}

#[derive(Parser, Debug)]
#[clap(version, name = "bbup-server")]
struct Args {
#[clap(subcommand)]
cmd: SubCommand,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
use crate::{ArchiveConfig, ArchiveState, CommmitListExt};
use crate::{ArchiveConfig, ArchiveState};

use bbup_rust::{
com::{BbupCom, JobType, Queryable},
fs::{self, AbstPath},
fstree::{Action, Delta},
model::Commit,
random,
};
use abst_fs::{self as fs, AbstPath};
use fs_vcs::{Action, Commit, Delta};

use bbup::com::{BbupCom, JobType, Queryable};

use std::sync::Arc;

Expand All @@ -27,9 +24,7 @@ async fn pull(
.commit_list
.get_update_delta(endpoint, last_known_commit)
.context("could not get update delta")?;
let id = state.commit_list[state.commit_list.len() - 1]
.commit_id
.clone();
let id = state.commit_list.most_recent_commit().commit_id.clone();

// send update delta to client for pull
com.send_struct(delta.clone())
Expand Down Expand Up @@ -177,7 +172,7 @@ async fn push(
}
}

let commit_id = random::random_hex(64);
let commit_id = Commit::gen_valid_id();
state.commit_list.push(Commit {
commit_id: commit_id.clone(),
endpoint: endpoint.clone(),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
use crate::smodel::ArchiveState;
use crate::ServerConfig;

use bbup_rust::fs::{list_dir_content, AbstPath, ObjectType};
use bbup_rust::fstree::FSTree;
use bbup_rust::input;
use bbup_rust::model::Commit;
use abst_fs::{list_dir_content, AbstPath, ObjectType};
use fs_vcs::{CommitList, FSTree};
// use bbup::model::Commit;

use anyhow::Result;

Expand All @@ -27,7 +26,7 @@ pub fn setup(home_dir: AbstPath) -> Result<()> {
}

ServerConfig::from(server_port, archive_root).save(&home_dir)?;
ArchiveState::from(vec![Commit::base_commit()], FSTree::empty())
ArchiveState::from(CommitList::base_commit_list(), FSTree::empty())
.save(&absolute_archive_root)?;

println!("bbup server set up correctly!");
Expand Down
Loading

0 comments on commit a7da2a3

Please sign in to comment.