From fcc5fbe564ee74e5f8434349424cbc4c646597df Mon Sep 17 00:00:00 2001 From: diogo464 Date: Sun, 11 Jul 2021 10:06:30 +0100 Subject: Fixed find_archive_path function. Fixed infinite loop if an archive file didnt exist. --- dotup_cli/src/utils.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/dotup_cli/src/utils.rs b/dotup_cli/src/utils.rs index 1ac8c95..fad37ae 100644 --- a/dotup_cli/src/utils.rs +++ b/dotup_cli/src/utils.rs @@ -15,15 +15,18 @@ pub fn home_directory() -> anyhow::Result { } pub fn find_archive_path() -> anyhow::Result { + let cwd = std::env::current_dir()?; + let compn = cwd.components().count(); let mut start = PathBuf::new(); - while { + for _ in 0..=compn { start.push(DEFAULT_DEPOT_NAME); - !start.is_file() - } { + if dotup::archive_exists(&start) { + return Ok(start); + } start.pop(); start.push(".."); } - Ok(start.canonicalize()?) + Ok(PathBuf::from(DEFAULT_DEPOT_NAME)) } pub fn write_archive(path: impl AsRef, archive: &Archive) -> anyhow::Result<()> { -- cgit