diff options
Diffstat (limited to 'src/lib/client.rs')
| -rw-r--r-- | src/lib/client.rs | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/lib/client.rs b/src/lib/client.rs index 01662cd..86e4097 100644 --- a/src/lib/client.rs +++ b/src/lib/client.rs | |||
| @@ -1325,14 +1325,22 @@ fn pb_after_style(succeed: bool) -> indicatif::ProgressStyle { | |||
| 1325 | } | 1325 | } |
| 1326 | 1326 | ||
| 1327 | async fn get_local_cache_database(git_repo_path: &Path) -> Result<NostrLMDB> { | 1327 | async fn get_local_cache_database(git_repo_path: &Path) -> Result<NostrLMDB> { |
| 1328 | NostrLMDB::open(git_repo_path.join(".git/nostr-cache.lmdb")) | 1328 | let git_dir = git2::Repository::discover(git_repo_path) |
| 1329 | .context("failed to open or create nostr cache database at .git/nostr-cache.lmdb") | 1329 | .context("failed to discover git repository")? |
| 1330 | .commondir() | ||
| 1331 | .to_path_buf(); | ||
| 1332 | NostrLMDB::open(git_dir.join("nostr-cache.lmdb")) | ||
| 1333 | .context("failed to open or create nostr cache database at <git-dir>/nostr-cache.lmdb") | ||
| 1330 | } | 1334 | } |
| 1331 | 1335 | ||
| 1332 | async fn get_global_cache_database(git_repo_path: Option<&Path>) -> Result<NostrLMDB> { | 1336 | async fn get_global_cache_database(git_repo_path: Option<&Path>) -> Result<NostrLMDB> { |
| 1333 | let path = if std::env::var("NGITTEST").is_ok() { | 1337 | let path = if std::env::var("NGITTEST").is_ok() { |
| 1334 | if let Some(git_repo_path) = git_repo_path { | 1338 | if let Some(git_repo_path) = git_repo_path { |
| 1335 | git_repo_path.join(".git/test-global-cache.lmdb") | 1339 | let git_dir = git2::Repository::discover(git_repo_path) |
| 1340 | .context("failed to discover git repository")? | ||
| 1341 | .commondir() | ||
| 1342 | .to_path_buf(); | ||
| 1343 | git_dir.join("test-global-cache.lmdb") | ||
| 1336 | } else { | 1344 | } else { |
| 1337 | bail!("git_repo must be supplied to get_global_cache_database during integration tests") | 1345 | bail!("git_repo must be supplied to get_global_cache_database during integration tests") |
| 1338 | } | 1346 | } |