Skip to content

Commit e7537de

Browse files
committed
fix(config): handle bin and repositories path
1 parent 5727e1a commit e7537de

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

soar-core/src/config.rs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ pub struct Repository {
7777
}
7878

7979
impl Repository {
80-
pub fn get_path(&self) -> Result<PathBuf> {
80+
pub fn get_path(&self) -> std::result::Result<PathBuf, SoarError> {
8181
Ok(get_config().get_repositories_path()?.join(&self.name))
8282
}
8383

@@ -273,8 +273,12 @@ impl Config {
273273
)?)
274274
}
275275

276-
pub fn get_bin_path(&self) -> Result<PathBuf> {
277-
Ok(self.default_profile()?.get_bin_path())
276+
pub fn get_bin_path(&self) -> std::result::Result<PathBuf, SoarError> {
277+
if let Some(bin_path) = &self.bin_path {
278+
build_path(bin_path)
279+
} else {
280+
Ok(self.default_profile()?.get_bin_path())
281+
}
278282
}
279283

280284
pub fn get_db_path(&self) -> std::result::Result<PathBuf, SoarError> {
@@ -294,8 +298,12 @@ impl Config {
294298
Ok(self.get_profile(&get_current_profile())?.get_cache_path())
295299
}
296300

297-
pub fn get_repositories_path(&self) -> Result<PathBuf> {
298-
Ok(self.default_profile()?.get_repositories_path())
301+
pub fn get_repositories_path(&self) -> std::result::Result<PathBuf, SoarError> {
302+
if let Some(repositories_path) = &self.repositories_path {
303+
build_path(repositories_path)
304+
} else {
305+
Ok(self.default_profile()?.get_repositories_path())
306+
}
299307
}
300308

301309
pub fn get_repository(&self, repo_name: &str) -> Option<&Repository> {

0 commit comments

Comments
 (0)