upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDanConwayDev <DanConwayDev@protonmail.com>2024-07-18 13:31:52 +0100
committerDanConwayDev <DanConwayDev@protonmail.com>2024-07-18 13:55:13 +0100
commiteb53b7ec0306fd0c1cc89203858d07676f4cce10 (patch)
tree8e5d17997faa951e4c5abde7a808456d91c98ec4
parent135697a06b5c8c6c6253e39d08afab0a87bace0e (diff)
refactor(fetch): move database cache
into cache directory rather than config directories also removed CodeCollaboration from path as this isn't helpful whilst this is a breaking change, the cache was only introduced during development of this version so it is not highlighted as such
-rw-r--r--src/client.rs10
-rw-r--r--src/config.rs2
2 files changed, 6 insertions, 6 deletions
diff --git a/src/client.rs b/src/client.rs
index 17e98b0..4e5a9d4 100644
--- a/src/client.rs
+++ b/src/client.rs
@@ -138,8 +138,8 @@ impl Connect for Client {
138 .opts(Options::new().relay_limits(RelayLimits::disable())) 138 .opts(Options::new().relay_limits(RelayLimits::disable()))
139 .signer(&opts.keys.unwrap_or(nostr::Keys::generate())) 139 .signer(&opts.keys.unwrap_or(nostr::Keys::generate()))
140 // .database( 140 // .database(
141 // SQLiteDatabase::open(get_dirs()?.config_dir().join("cache.sqlite")).await?, 141 // SQLiteDatabase::open(get_dirs()?.cache_dir().join("nostr-cache.sqlite")).
142 // ) 142 // await?, )
143 .build(), 143 .build(),
144 fallback_relays: opts.fallback_relays, 144 fallback_relays: opts.fallback_relays,
145 more_fallback_relays: opts.more_fallback_relays, 145 more_fallback_relays: opts.more_fallback_relays,
@@ -689,11 +689,11 @@ async fn get_local_cache_database(git_repo_path: &Path) -> Result<SQLiteDatabase
689 689
690async fn get_global_cache_database(git_repo_path: &Path) -> Result<SQLiteDatabase> { 690async fn get_global_cache_database(git_repo_path: &Path) -> Result<SQLiteDatabase> {
691 SQLiteDatabase::open(if std::env::var("NGITTEST").is_err() { 691 SQLiteDatabase::open(if std::env::var("NGITTEST").is_err() {
692 create_dir_all(get_dirs()?.config_dir()).context(format!( 692 create_dir_all(get_dirs()?.cache_dir()).context(format!(
693 "cannot create cache directory in: {:?}", 693 "cannot create cache directory in: {:?}",
694 get_dirs()?.config_dir() 694 get_dirs()?.cache_dir()
695 ))?; 695 ))?;
696 get_dirs()?.config_dir().join("cache.sqlite") 696 get_dirs()?.cache_dir().join("nostr-cache.sqlite")
697 } else { 697 } else {
698 git_repo_path.join(".git/test-global-cache.sqlite") 698 git_repo_path.join(".git/test-global-cache.sqlite")
699 }) 699 })
diff --git a/src/config.rs b/src/config.rs
index f5dba98..547fe7e 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -5,7 +5,7 @@ use nostr_sdk::Timestamp;
5use serde::{self, Deserialize, Serialize}; 5use serde::{self, Deserialize, Serialize};
6 6
7pub fn get_dirs() -> Result<ProjectDirs> { 7pub fn get_dirs() -> Result<ProjectDirs> {
8 ProjectDirs::from("", "CodeCollaboration", "ngit").ok_or(anyhow!( 8 ProjectDirs::from("", "", "ngit").ok_or(anyhow!(
9 "should find operating system home directories with rust-directories crate" 9 "should find operating system home directories with rust-directories crate"
10 )) 10 ))
11} 11}