From b8d50338cd43efb0f8919dfeb15fb5e5068e68eb Mon Sep 17 00:00:00 2001 From: Jenna Johnson Date: Mon, 1 Apr 2024 10:12:44 -0400 Subject: [PATCH] total module restructure --- src/cmd/add_cmd.rs | 56 -------- src/cmd/get_cmd.rs | 28 ---- src/cmd/init_cmd.rs | 14 -- src/cmd/mod.rs | 4 - src/{internal/config => helpers}/config.rs | 0 src/{internal/storage => helpers}/copy.rs | 0 src/{internal/meta => helpers}/file.rs | 0 src/{internal/file => helpers}/hash.rs | 0 src/{internal/git => helpers}/ignore.rs | 2 +- src/helpers/mod.rs | 7 + src/{internal/meta => helpers}/parse.rs | 0 src/{internal/git => helpers}/repo.rs | 0 src/internal/config/mod.rs | 1 - src/internal/file/mod.rs | 1 - src/internal/git/mod.rs | 2 - src/internal/meta/mod.rs | 2 - src/internal/migrate/mod.rs | 0 src/internal/mod.rs | 7 - src/internal/storage/add.rs | 69 ---------- src/internal/storage/mod.rs | 4 - src/internal/utils/mod.rs | 1 - src/internal/utils/utils.rs | 28 ---- src/library/add.rs | 131 +++++++++++++++++++ src/{internal/storage => library}/get.rs | 31 ++++- src/{internal/storage => library}/init.rs | 13 +- src/library/mod.rs | 4 + src/{cmd/status_cmd.rs => library/status.rs} | 12 +- src/main.rs | 26 ++-- 28 files changed, 199 insertions(+), 244 deletions(-) delete mode 100644 src/cmd/add_cmd.rs delete mode 100644 src/cmd/get_cmd.rs delete mode 100644 src/cmd/init_cmd.rs delete mode 100644 src/cmd/mod.rs rename src/{internal/config => helpers}/config.rs (100%) rename src/{internal/storage => helpers}/copy.rs (100%) rename src/{internal/meta => helpers}/file.rs (100%) rename src/{internal/file => helpers}/hash.rs (100%) rename src/{internal/git => helpers}/ignore.rs (97%) create mode 100644 src/helpers/mod.rs rename src/{internal/meta => helpers}/parse.rs (100%) rename src/{internal/git => helpers}/repo.rs (100%) delete mode 100644 src/internal/config/mod.rs delete mode 100644 src/internal/file/mod.rs delete mode 100644 src/internal/git/mod.rs delete mode 100644 src/internal/meta/mod.rs delete mode 100644 src/internal/migrate/mod.rs delete mode 100644 src/internal/mod.rs delete mode 100644 src/internal/storage/add.rs delete mode 100644 src/internal/storage/mod.rs delete mode 100644 src/internal/utils/mod.rs delete mode 100644 src/internal/utils/utils.rs create mode 100644 src/library/add.rs rename src/{internal/storage => library}/get.rs (52%) rename src/{internal/storage => library}/init.rs (82%) create mode 100644 src/library/mod.rs rename src/{cmd/status_cmd.rs => library/status.rs} (92%) diff --git a/src/cmd/add_cmd.rs b/src/cmd/add_cmd.rs deleted file mode 100644 index 4dbc1ec..0000000 --- a/src/cmd/add_cmd.rs +++ /dev/null @@ -1,56 +0,0 @@ -use std::path::PathBuf; -use crate::internal::git::repo; -use crate::internal::storage::add; -use crate::internal::config::config; -use anyhow::{Context, Result}; - -pub fn run_add_cmd(files: &Vec, message: &String) -> Result<()> { - // Get git root - let git_dir = repo::get_nearest_repo_dir(&PathBuf::from(".")).with_context(|| "could not find git repo root - make sure you're in an active git repository")?; - - // load the config - let conf = config::read(&git_dir)?; - - let mut queued_paths: Vec = Vec::new(); - - for file_in in files { - let file_without_meta = file_in.replace(".dvsmeta", ""); - let file = PathBuf::from(file_without_meta); - - if queued_paths.contains(&file) {continue} - - // ensure file is inside of the git repo - let abs_path = match file.canonicalize() { - Ok(file) => file, - Err(_) => { // swallowing error here because the command can still run - println!("skipping {} - doesn't exist", file.display()); - continue; - } - }; - if abs_path.strip_prefix(&git_dir).unwrap() == abs_path { - println!("skipping {} - outside of git repository", file.display()); - continue; - } - - // skip directories - if file.is_dir() { - println!("skipping {} - is a directory", file.display()); - continue - } - - // all checks passed, finally add file to queued_paths - queued_paths.push(file); - } // for - - - // add each file in queued_paths to storage - for file in &queued_paths { - add::add(file, &conf, &message)?; - } - - if queued_paths.is_empty() { - // json warning: no files were queued - } - - Ok(()) -} // run_add_cmd \ No newline at end of file diff --git a/src/cmd/get_cmd.rs b/src/cmd/get_cmd.rs deleted file mode 100644 index 4d617c3..0000000 --- a/src/cmd/get_cmd.rs +++ /dev/null @@ -1,28 +0,0 @@ -use std::path::PathBuf; -use anyhow::{Context, Result}; -use crate::internal::config::config; -use crate::internal::git::repo; -use crate::internal::meta::parse; -use crate::internal::storage::get; - -pub fn run_get_cmd(globs: &Vec) -> Result<()> { - // Get git root - let git_dir = repo::get_nearest_repo_dir(&PathBuf::from(".")).with_context(|| "could not find git repo root - make sure you're in an active git repository")?; - - // load the config - let conf = config::read(&git_dir).with_context(|| "dvs.yaml is not present in your directory - have you initialized devious?")?; - - // parse each glob - let queued_paths = parse::parse_globs(globs); - - // Get the queued files - for path in &queued_paths { - get::get(&path, &conf.storage_dir).with_context(|| format!("could not retrieve {} from storage directory", path.display()))?; - } - - if queued_paths.is_empty() { - println!("warning: no files were queued") - } - - Ok(()) -} \ No newline at end of file diff --git a/src/cmd/init_cmd.rs b/src/cmd/init_cmd.rs deleted file mode 100644 index 4cd2130..0000000 --- a/src/cmd/init_cmd.rs +++ /dev/null @@ -1,14 +0,0 @@ -use crate::internal::git::repo; -use crate::internal::storage::init; -use std::path::PathBuf; -use anyhow::{Context, Result}; - -pub fn run_init_cmd(storage_dir: &PathBuf, mode: &u32, group: &String) -> Result<()> { - // Get git root - let git_dir = repo::get_nearest_repo_dir(&PathBuf::from(".")).with_context(|| "could not find git repo root - make sure you're in an active git repository")?; - - // Initialize - init::init(&git_dir, &storage_dir, &mode, &group)?; - - Ok(()) -} \ No newline at end of file diff --git a/src/cmd/mod.rs b/src/cmd/mod.rs deleted file mode 100644 index a5c6c5e..0000000 --- a/src/cmd/mod.rs +++ /dev/null @@ -1,4 +0,0 @@ -pub mod init_cmd; -pub mod add_cmd; -pub mod get_cmd; -pub mod status_cmd; \ No newline at end of file diff --git a/src/internal/config/config.rs b/src/helpers/config.rs similarity index 100% rename from src/internal/config/config.rs rename to src/helpers/config.rs diff --git a/src/internal/storage/copy.rs b/src/helpers/copy.rs similarity index 100% rename from src/internal/storage/copy.rs rename to src/helpers/copy.rs diff --git a/src/internal/meta/file.rs b/src/helpers/file.rs similarity index 100% rename from src/internal/meta/file.rs rename to src/helpers/file.rs diff --git a/src/internal/file/hash.rs b/src/helpers/hash.rs similarity index 100% rename from src/internal/file/hash.rs rename to src/helpers/hash.rs diff --git a/src/internal/git/ignore.rs b/src/helpers/ignore.rs similarity index 97% rename from src/internal/git/ignore.rs rename to src/helpers/ignore.rs index 1c60672..8400bd8 100644 --- a/src/internal/git/ignore.rs +++ b/src/helpers/ignore.rs @@ -1,5 +1,5 @@ use std::{fs::{File, OpenOptions}, path::PathBuf}; -use crate::internal::git::repo; +use crate::helpers::repo; use std::io::prelude::*; use anyhow::{Context, Result}; diff --git a/src/helpers/mod.rs b/src/helpers/mod.rs new file mode 100644 index 0000000..0f861ee --- /dev/null +++ b/src/helpers/mod.rs @@ -0,0 +1,7 @@ +pub mod config; +pub mod file; +pub mod copy; +pub mod hash; +pub mod ignore; +pub mod repo; +pub mod parse; \ No newline at end of file diff --git a/src/internal/meta/parse.rs b/src/helpers/parse.rs similarity index 100% rename from src/internal/meta/parse.rs rename to src/helpers/parse.rs diff --git a/src/internal/git/repo.rs b/src/helpers/repo.rs similarity index 100% rename from src/internal/git/repo.rs rename to src/helpers/repo.rs diff --git a/src/internal/config/mod.rs b/src/internal/config/mod.rs deleted file mode 100644 index a105933..0000000 --- a/src/internal/config/mod.rs +++ /dev/null @@ -1 +0,0 @@ -pub mod config; \ No newline at end of file diff --git a/src/internal/file/mod.rs b/src/internal/file/mod.rs deleted file mode 100644 index 12950c5..0000000 --- a/src/internal/file/mod.rs +++ /dev/null @@ -1 +0,0 @@ -pub mod hash; \ No newline at end of file diff --git a/src/internal/git/mod.rs b/src/internal/git/mod.rs deleted file mode 100644 index 34f113a..0000000 --- a/src/internal/git/mod.rs +++ /dev/null @@ -1,2 +0,0 @@ -pub mod repo; -pub mod ignore; \ No newline at end of file diff --git a/src/internal/meta/mod.rs b/src/internal/meta/mod.rs deleted file mode 100644 index 99e3888..0000000 --- a/src/internal/meta/mod.rs +++ /dev/null @@ -1,2 +0,0 @@ -pub mod file; -pub mod parse; \ No newline at end of file diff --git a/src/internal/migrate/mod.rs b/src/internal/migrate/mod.rs deleted file mode 100644 index e69de29..0000000 diff --git a/src/internal/mod.rs b/src/internal/mod.rs deleted file mode 100644 index 632ee21..0000000 --- a/src/internal/mod.rs +++ /dev/null @@ -1,7 +0,0 @@ -pub mod config; -pub mod file; -pub mod git; -pub mod meta; -pub mod migrate; -pub mod storage; -pub mod utils; \ No newline at end of file diff --git a/src/internal/storage/add.rs b/src/internal/storage/add.rs deleted file mode 100644 index a3f607c..0000000 --- a/src/internal/storage/add.rs +++ /dev/null @@ -1,69 +0,0 @@ -use std::os::unix::fs::PermissionsExt; -use std::path::PathBuf; -use file_owner::{Group, PathExt}; -use std::fs; -use anyhow::{anyhow, Context, Result}; -use crate::internal::config::config::Config; -use crate::internal::file::hash; -use crate::internal::storage::copy; -use crate::internal::meta::file; -use crate::internal::git::ignore; - - -pub fn add(local_path: &PathBuf, conf: &Config, message: &String) -> Result { - // get file hash - let file_hash = hash::hash_file_with_blake3(local_path).with_context(|| format!("could not hash file"))?; - - // get storage path - let storage_dir_abs = conf.storage_dir.canonicalize().with_context(|| format!("could not find storage directory: {}", conf.storage_dir.display()))?; - let dest_path = hash::get_storage_path(&storage_dir_abs, &file_hash); - - // check if group exists again - let group = Group::from_name(&conf.group).with_context(|| format!("group not found: {}", conf.group))?; - - // Copy the file to the storage directory - // if the destination already exists, skip copying - if !dest_path.exists() { - // copy - copy::copy(&local_path, &dest_path).with_context(|| format!("could not copy {} to storage directory: {}", local_path.display(), dest_path.display()))?; - } - else { - println!("{} already exists in storage directory", local_path.display()) - } - - // set permissions - let mode = conf.permissions; - dest_path.metadata().unwrap().permissions().set_mode(mode); - let _file_mode = dest_path.metadata().unwrap().permissions().mode(); - //let new_permissions = fs::Permissions::from_mode(mode); - //fs::set_permissions(&dest_path, new_permissions).with_context(|| format!("unable to set permissions: {}", mode))?; - - // set group ownership - dest_path.set_group( group).with_context(|| format!("unable to set group: {}", group))?; - - // get file size - let local_path_data = local_path.metadata().with_context(|| format!("unable to get size of file: {}", local_path.display()))?; - let file_size = local_path_data.len(); - - // get user name - let owner = local_path.owner().with_context(|| format!(""))?; - let owner_name = match owner.name() { - Ok(name) => name.unwrap(), - Err(e) => {return Err(anyhow!("could not get name of file owner: {e}"))}, - }; - - // create + write metadata file - let metadata = file::Metadata{ - file_hash: file_hash.clone(), - file_size, - time_stamp: chrono::offset::Local::now().to_string(), - message: message.clone(), - saved_by: owner_name - }; - file::save(&metadata, &local_path).with_context(|| format!("could not save metadata into file"))?; - - // Add file to gitignore - ignore::add_gitignore_entry(local_path).with_context(|| format!("could not add .gitignore entry"))?; - - return Ok(file_hash); -} \ No newline at end of file diff --git a/src/internal/storage/mod.rs b/src/internal/storage/mod.rs deleted file mode 100644 index 7baf7cf..0000000 --- a/src/internal/storage/mod.rs +++ /dev/null @@ -1,4 +0,0 @@ -pub mod init; -pub mod add; -pub mod copy; -pub mod get; \ No newline at end of file diff --git a/src/internal/utils/mod.rs b/src/internal/utils/mod.rs deleted file mode 100644 index fab870e..0000000 --- a/src/internal/utils/mod.rs +++ /dev/null @@ -1 +0,0 @@ -pub mod utils; \ No newline at end of file diff --git a/src/internal/utils/utils.rs b/src/internal/utils/utils.rs deleted file mode 100644 index 9ee1998..0000000 --- a/src/internal/utils/utils.rs +++ /dev/null @@ -1,28 +0,0 @@ -// use std::path::{Component, Path, PathBuf}; - -// pub fn normalize_path(path: &Path) -> PathBuf { -// let mut components = path.components().peekable(); -// let mut ret = if let Some(c @ Component::Prefix(..)) = components.peek().cloned() { -// components.next(); -// PathBuf::from(c.as_os_str()) -// } else { -// PathBuf::new() -// }; - -// for component in components { -// match component { -// Component::Prefix(..) => unreachable!(), -// Component::RootDir => { -// ret.push(component.as_os_str()); -// } -// Component::CurDir => {} -// Component::ParentDir => { -// ret.pop(); -// } -// Component::Normal(c) => { -// ret.push(c); -// } -// } -// } -// ret -// } \ No newline at end of file diff --git a/src/library/add.rs b/src/library/add.rs new file mode 100644 index 0000000..27e2443 --- /dev/null +++ b/src/library/add.rs @@ -0,0 +1,131 @@ +use std::path::PathBuf; +use std::os::unix::fs::PermissionsExt; +use file_owner::{Group, PathExt}; +use std::{fs, u32}; +use anyhow::{anyhow, Context, Result}; +use crate::helpers::hash; +use crate::helpers::copy; +use crate::helpers::file; +use crate::helpers::ignore; +use crate::helpers::config; +use crate::helpers::repo; + +pub fn dvs_add(files: &Vec, message: &String) -> Result<()> { + // Get git root + let git_dir = repo::get_nearest_repo_dir(&PathBuf::from(".")).with_context(|| "could not find git repo root - make sure you're in an active git repository")?; + + // load the config + let conf = config::read(&git_dir)?; + + let mut queued_paths: Vec = Vec::new(); + + for file_in in files { + let file_without_meta = file_in.replace(".dvsmeta", ""); + let file = PathBuf::from(file_without_meta); + + if queued_paths.contains(&file) {continue} + + // ensure file is inside of the git repo + let abs_path = match file.canonicalize() { + Ok(file) => file, + Err(_) => { // swallowing error here because the command can still run + println!("skipping {} - doesn't exist", file.display()); + continue; + } + }; + if abs_path.strip_prefix(&git_dir).unwrap() == abs_path { + println!("skipping {} - outside of git repository", file.display()); + continue; + } + + // skip directories + if file.is_dir() { + println!("skipping {} - is a directory", file.display()); + continue + } + + // all checks passed, finally add file to queued_paths + queued_paths.push(file); + } // for + + + // add each file in queued_paths to storage + for file in &queued_paths { + add(file, &conf, &message)?; + } + + if queued_paths.is_empty() { + // json warning: no files were queued + } + + Ok(()) +} // run_add_cmd + +fn add(local_path: &PathBuf, conf: &config::Config, message: &String) -> Result { + // get file hash + let file_hash = hash::hash_file_with_blake3(local_path).with_context(|| format!("could not hash file"))?; + + // get storage path + let storage_dir_abs = conf.storage_dir.canonicalize().with_context(|| format!("could not find storage directory: {}", conf.storage_dir.display()))?; + let dest_path = hash::get_storage_path(&storage_dir_abs, &file_hash); + + // check if group exists again + let group = Group::from_name(&conf.group).with_context(|| format!("group not found: {}", conf.group))?; + + // Copy the file to the storage directory if it's not already there + if !dest_path.exists() { + // copy + copy::copy(&local_path, &dest_path).with_context(|| format!("could not copy {} to storage directory: {}", local_path.display(), dest_path.display()))?; + } + else { + println!("{} already exists in storage directory", local_path.display()) + } + + // set permissions + set_permissions(&conf.permissions, &dest_path)?; + + // set group ownership + dest_path.set_group(group).with_context(|| format!("unable to set group: {}", group))?; + + // get file size + let file_size = get_file_size(&local_path)?; + + // get user name + let user_name = get_user_name(&local_path)?; + + // create + write metadata file + let metadata = file::Metadata{ + file_hash: file_hash.clone(), + file_size, + time_stamp: chrono::offset::Local::now().to_string(), + message: message.clone(), + saved_by: user_name + }; + file::save(&metadata, &local_path).with_context(|| format!("could not save metadata into file"))?; + + // Add file to gitignore + ignore::add_gitignore_entry(local_path).with_context(|| format!("could not add .gitignore entry"))?; + + return Ok(file_hash); +} + +fn set_permissions(mode: &u32, dest_path: &PathBuf) -> Result<()> { + dest_path.metadata().unwrap().permissions().set_mode(*mode); + let _file_mode = dest_path.metadata().unwrap().permissions().mode(); + let new_permissions = fs::Permissions::from_mode(*mode); + fs::set_permissions(&dest_path, new_permissions).with_context(|| format!("unable to set permissions: {}", mode))?; + Ok(()) +} + +fn get_file_size(local_path: &PathBuf) -> Result { + let local_path_data = local_path.metadata().with_context(|| format!("unable to get size of file: {}", local_path.display()))?; + return Ok(local_path_data.len()); +} + +fn get_user_name(local_path: &PathBuf) -> Result { + let owner = local_path.owner().with_context(|| format!(""))?; + match owner.name() { + Ok(name) => return Ok(name.unwrap()), + Err(e) => return Err(anyhow!("could not get name of file owner: {e}")), + }; +} \ No newline at end of file diff --git a/src/internal/storage/get.rs b/src/library/get.rs similarity index 52% rename from src/internal/storage/get.rs rename to src/library/get.rs index 91559d2..57f4a50 100644 --- a/src/internal/storage/get.rs +++ b/src/library/get.rs @@ -1,8 +1,33 @@ use std::path::PathBuf; use anyhow::{Context, Result}; -use crate::internal::file::hash; -use crate::internal::meta::file; -use crate::internal::storage::copy; +use crate::helpers::hash; +use crate::helpers::copy; +use crate::helpers::file; +use crate::helpers::config; +use crate::helpers::repo; +use crate::helpers::parse; + +pub fn dvs_get(globs: &Vec) -> Result<()> { + // Get git root + let git_dir = repo::get_nearest_repo_dir(&PathBuf::from(".")).with_context(|| "could not find git repo root - make sure you're in an active git repository")?; + + // load the config + let conf = config::read(&git_dir).with_context(|| "dvs.yaml is not present in your directory - have you initialized devious?")?; + + // parse each glob + let queued_paths = parse::parse_globs(globs); + + // Get the queued files + for path in &queued_paths { + get(&path, &conf.storage_dir).with_context(|| format!("could not retrieve {} from storage directory", path.display()))?; + } + + if queued_paths.is_empty() { + println!("warning: no files were queued") + } + + Ok(()) +} // gets a file from storage pub fn get(local_path: &PathBuf, storage_dir: &PathBuf) -> Result<()> { diff --git a/src/internal/storage/init.rs b/src/library/init.rs similarity index 82% rename from src/internal/storage/init.rs rename to src/library/init.rs index ee60e06..6b6a6f8 100644 --- a/src/internal/storage/init.rs +++ b/src/library/init.rs @@ -1,12 +1,15 @@ -use crate::internal::config::config; -use crate::internal::git::repo; +use crate::helpers::repo; use std::path::PathBuf; +use crate::helpers::config; use std::fs::create_dir; use path_absolutize::Absolutize; use file_owner::Group; use anyhow::{anyhow, Context, Result}; -pub fn init(root_dir: &PathBuf, storage_dir: &PathBuf, mode: &u32, group_name: &String) -> Result<()> { +pub fn dvs_init(storage_dir: &PathBuf, mode: &u32, group_name: &String) -> Result<()> { + // Get git root + let git_dir = repo::get_nearest_repo_dir(&PathBuf::from(".")).with_context(|| "could not find git repo root - make sure you're in an active git repository")?; + // get absolute path, but don't check if it exists yet let storage_dir_abs = PathBuf::from(storage_dir.absolutize().unwrap()); @@ -42,9 +45,9 @@ pub fn init(root_dir: &PathBuf, storage_dir: &PathBuf, mode: &u32, group_name: & &config::Config{storage_dir: storage_dir_abs.clone(), permissions: mode.clone(), group: group_name.clone()}, - &root_dir) + &git_dir) .with_context(|| "unable to write configuration file")?; Ok(()) // json: success -} \ No newline at end of file +} diff --git a/src/library/mod.rs b/src/library/mod.rs new file mode 100644 index 0000000..92d450d --- /dev/null +++ b/src/library/mod.rs @@ -0,0 +1,4 @@ +pub mod init; +pub mod add; +pub mod get; +pub mod status; \ No newline at end of file diff --git a/src/cmd/status_cmd.rs b/src/library/status.rs similarity index 92% rename from src/cmd/status_cmd.rs rename to src/library/status.rs index 7e620d3..a8b38f7 100644 --- a/src/cmd/status_cmd.rs +++ b/src/library/status.rs @@ -1,10 +1,12 @@ use std::path::PathBuf; use anyhow::{Context, Result}; use serde::{Serialize, Deserialize}; -use crate::internal::config::config; -use crate::internal::file::hash; -use crate::internal::git::repo; -use crate::internal::meta::{file, parse}; +use crate::helpers::config; +use crate::helpers::hash; +use crate::helpers::repo; +use crate::helpers::file; +use crate::helpers::parse; + #[derive(Serialize, Deserialize, PartialEq, Debug)] pub struct JsonFileResult { @@ -17,7 +19,7 @@ pub struct JsonFileResult { pub message: String } -pub fn run_status_cmd(files: &Vec) -> Result> { +pub fn dvs_status(files: &Vec) -> Result> { // struct for each file's status and such let mut json_logger: Vec = Vec::new(); diff --git a/src/main.rs b/src/main.rs index b4cac2d..a9b3592 100644 --- a/src/main.rs +++ b/src/main.rs @@ -4,12 +4,12 @@ use anyhow::Result; use std::fs::{self, File}; use std::os::unix::fs::PermissionsExt; -mod internal; -mod cmd; -use crate::cmd::init_cmd; -use crate::cmd::add_cmd; -use crate::cmd::get_cmd; -use crate::cmd::status_cmd; +mod helpers; +mod library; +use crate::library::init; +use crate::library::add; +use crate::library::get; +use crate::library::status; fn main() -> Result<()> { // write files @@ -38,12 +38,12 @@ fn main() -> Result<()> { let storage_dir = PathBuf::from(r"src/test_directory_storage"); let new_mode = 0o776; let group = String::from("datascience"); - init_cmd::run_init_cmd(&storage_dir, &new_mode, &group)?; + init::dvs_init(&storage_dir, &new_mode, &group)?; // dvs add src/test_directory/test1.txt src/test_directory/test2.txt src/test_directory/test3.txt "assembled data" let files: Vec = vec![test1_path.clone(), test2_path.clone(), test3_path.clone()]; let message = String::from("assembled data"); - add_cmd::run_add_cmd(&files, &message)?; + add::dvs_add(&files, &message)?; // TODO: check permissions and group // let test1_storage = PathBuf::from("src/test_directory_storage/7f/08b8682ee8258389605201d65ed6a9104eed809c000d7975186bc4cd8a3efe"); @@ -63,24 +63,24 @@ fn main() -> Result<()> { // keep test3.txt the same // dvs status - let status = status_cmd::run_status_cmd(&Vec::new())?; + let status = status::dvs_status(&Vec::new())?; let status_string = serde_json::to_string_pretty(&status).unwrap(); println!("new status:\n{status_string}"); // dvs get src/test_directory/test1.txt - get_cmd::run_get_cmd(&vec![test1_path.clone()])?; + get::dvs_get(&vec![test1_path.clone()])?; // dvs status src/test_directory/test1.txt - let status = status_cmd::run_status_cmd(&vec![test1_path.clone()])?; + let status = status::dvs_status(&vec![test1_path.clone()])?; let status_string = serde_json::to_string_pretty(&status).unwrap(); println!("new status:\n{status_string}"); // dvs add rc/test_directory/test2.txt "assembled data again" let message = String::from("assembled data again"); - add_cmd::run_add_cmd(&vec![test2_path.clone()], &message)?; + add::dvs_add(&vec![test2_path.clone()], &message)?; // dvs status src/test_directory/test1.txt src/test_directory/test2.txt src/test_directory/test3.txt - let status = status_cmd::run_status_cmd(&vec![test1_path.clone(), test2_path.clone(), test3_path.clone()])?; + let status = status::dvs_status(&vec![test1_path.clone(), test2_path.clone(), test3_path.clone()])?; let status_string = serde_json::to_string_pretty(&status).unwrap(); println!("new status:\n{status_string}");