diff options
Diffstat (limited to 'dotup_cli/src/utils.rs')
| -rw-r--r-- | dotup_cli/src/utils.rs | 11 |
1 files 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<PathBuf> { | |||
| 15 | } | 15 | } |
| 16 | 16 | ||
| 17 | pub fn find_archive_path() -> anyhow::Result<PathBuf> { | 17 | pub fn find_archive_path() -> anyhow::Result<PathBuf> { |
| 18 | let cwd = std::env::current_dir()?; | ||
| 19 | let compn = cwd.components().count(); | ||
| 18 | let mut start = PathBuf::new(); | 20 | let mut start = PathBuf::new(); |
| 19 | while { | 21 | for _ in 0..=compn { |
| 20 | start.push(DEFAULT_DEPOT_NAME); | 22 | start.push(DEFAULT_DEPOT_NAME); |
| 21 | !start.is_file() | 23 | if dotup::archive_exists(&start) { |
| 22 | } { | 24 | return Ok(start); |
| 25 | } | ||
| 23 | start.pop(); | 26 | start.pop(); |
| 24 | start.push(".."); | 27 | start.push(".."); |
| 25 | } | 28 | } |
| 26 | Ok(start.canonicalize()?) | 29 | Ok(PathBuf::from(DEFAULT_DEPOT_NAME)) |
| 27 | } | 30 | } |
| 28 | 31 | ||
| 29 | pub fn write_archive(path: impl AsRef<Path>, archive: &Archive) -> anyhow::Result<()> { | 32 | pub fn write_archive(path: impl AsRef<Path>, archive: &Archive) -> anyhow::Result<()> { |
