diff --git a/coffee_core/src/coffee.rs b/coffee_core/src/coffee.rs index 98e32c9..c60244d 100644 --- a/coffee_core/src/coffee.rs +++ b/coffee_core/src/coffee.rs @@ -383,7 +383,8 @@ impl PluginManager for CoffeeManager { if self.repos.contains_key(name) { return Err(error!("repository with name: {name} already exists")); } - let url = URL::new(&self.config.root_path, url, name); + let local_path = format!("{}/{}", self.config.root_path, self.config.network); + let url = URL::new(&local_path, url, name); log::debug!("remote adding: {} {}", name, &url.url_string); let mut repo = Github::new(name, &url); repo.init().await?; diff --git a/coffee_core/src/config.rs b/coffee_core/src/config.rs index c0bb9b0..bd43eb1 100644 --- a/coffee_core/src/config.rs +++ b/coffee_core/src/config.rs @@ -4,7 +4,7 @@ use serde::{Deserialize, Serialize}; use std::env; use crate::CoffeeOperation; -use coffee_lib::utils::check_dir_or_make_if_missing; +use coffee_lib::utils::{check_dir_or_make_if_missing, move_dir_if_exist}; use coffee_lib::{errors::CoffeeError, plugin::Plugin}; use crate::CoffeeArgs; @@ -65,7 +65,9 @@ impl CoffeeConf { check_dir_or_make_if_missing(format!("{def_path}/{}", coffee.network)).await?; check_dir_or_make_if_missing(format!("{def_path}/{}/plugins", coffee.network)).await?; - check_dir_or_make_if_missing(format!("{def_path}/repositories")).await?; + let repo_dir = format!("{def_path}/{}/repositories", coffee.network); + move_dir_if_exist(&format!("{def_path}/repositories"), &repo_dir).await?; + check_dir_or_make_if_missing(repo_dir).await?; // after we know all the information regarding // the configuration we try to see if there is // something stored already to the disk. diff --git a/coffee_lib/src/utils.rs b/coffee_lib/src/utils.rs index 3f46a6d..5c5c69e 100644 --- a/coffee_lib/src/utils.rs +++ b/coffee_lib/src/utils.rs @@ -2,6 +2,7 @@ use super::macros::error; use std::path::Path; use tokio::fs::create_dir; +use tokio::fs::rename; use crate::errors::CoffeeError; @@ -28,6 +29,14 @@ pub async fn check_dir_or_make_if_missing(path: String) -> Result<(), CoffeeErro Ok(()) } +pub async fn move_dir_if_exist(origin: &str, destination: &str) -> Result<(), CoffeeError> { + if Path::exists(Path::new(&origin)) { + rename(origin, destination).await?; + log::debug!("move dir from {origin} to {destination}"); + } + Ok(()) +} + #[cfg(test)] mod tests { use std::fs::create_dir_all; diff --git a/git-bugreport-2024-02-07-1353.txt b/git-bugreport-2024-02-07-1353.txt new file mode 100644 index 0000000..f278341 --- /dev/null +++ b/git-bugreport-2024-02-07-1353.txt @@ -0,0 +1,32 @@ +Thank you for filling out a Git bug report! +Please answer the following questions to help us understand your issue. + +What did you do before the bug happened? (Steps to reproduce your issue) + +What did you expect to happen? (Expected behavior) + +What happened instead? (Actual behavior) + +What's different between what you expected and what actually happened? + +Anything else you want to add: + +Please review the rest of the bug report below. +You can delete any lines you don't wish to share. + + +[System Info] +git version: +git version 2.43.0 +cpu: x86_64 +no commit associated with this build +sizeof-long: 8 +sizeof-size_t: 8 +shell-path: /bin/sh +uname: Linux 6.6.15-2-lts #1 SMP PREEMPT_DYNAMIC Fri, 02 Feb 2024 17:04:24 +0000 x86_64 +compiler info: gnuc: 13.2 +libc info: glibc: 2.39 +$SHELL (typically, interactive shell): /usr/bin/zsh + + +[Enabled Hooks]