aboutsummaryrefslogtreecommitdiff
path: root/src/guilds.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/guilds.rs')
-rw-r--r--src/guilds.rs13
1 files changed, 4 insertions, 9 deletions
diff --git a/src/guilds.rs b/src/guilds.rs
index 0eff6ad..24ec817 100644
--- a/src/guilds.rs
+++ b/src/guilds.rs
@@ -1,7 +1,8 @@
//! Guild name retrieval and caching functions.
+use super::paths;
+
use std::collections::HashMap;
use std::fs::File;
-use std::path::PathBuf;
use std::sync::RwLock;
use once_cell::sync::Lazy;
@@ -52,15 +53,9 @@ pub fn lookup(api_id: &str) -> Option<Guild> {
Some(guild)
}
-fn cache_path() -> PathBuf {
- let mut cache_path = dirs::cache_dir().unwrap();
- cache_path.push("raidgrep");
- cache_path
-}
-
/// Loads the cache from the file system.
pub fn prepare_cache() {
- let path = cache_path();
+ let path = paths::cache_path();
if !path.is_file() {
return;
}
@@ -73,7 +68,7 @@ pub fn prepare_cache() {
/// Saves the cache to the file system
pub fn save_cache() {
- let path = cache_path();
+ let path = paths::cache_path();
let file = File::create(path).expect("Cannot open cache for writing");
serde_json::to_writer(file, &*CACHE.read().unwrap()).unwrap();
}