cache: store all cached data under XDG_CACHE_HOME
Both cache.json (article list) and the images directory are regeneratable from the server, so they belong in XDG_CACHE_HOME (~/.cache/net.jeena.FeedTheMonkey/) rather than XDG_DATA_HOME.
This commit is contained in:
parent
fda441bebd
commit
8e21c80a33
2 changed files with 3 additions and 3 deletions
|
|
@ -6,7 +6,7 @@ pub struct Cache {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn save(articles: &[Article], selected_id: &str) {
|
pub fn save(articles: &[Article], selected_id: &str) {
|
||||||
let dir = glib::user_data_dir().join("net.jeena.FeedTheMonkey");
|
let dir = glib::user_cache_dir().join("net.jeena.FeedTheMonkey");
|
||||||
std::fs::create_dir_all(&dir).ok();
|
std::fs::create_dir_all(&dir).ok();
|
||||||
let data = serde_json::json!({
|
let data = serde_json::json!({
|
||||||
"articles": articles,
|
"articles": articles,
|
||||||
|
|
@ -18,7 +18,7 @@ pub fn save(articles: &[Article], selected_id: &str) {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn load() -> Option<Cache> {
|
pub fn load() -> Option<Cache> {
|
||||||
let path = glib::user_data_dir()
|
let path = glib::user_cache_dir()
|
||||||
.join("net.jeena.FeedTheMonkey")
|
.join("net.jeena.FeedTheMonkey")
|
||||||
.join("cache.json");
|
.join("cache.json");
|
||||||
let data = std::fs::read_to_string(path).ok()?;
|
let data = std::fs::read_to_string(path).ok()?;
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ use std::path::PathBuf;
|
||||||
use crate::model::Article;
|
use crate::model::Article;
|
||||||
|
|
||||||
fn images_dir() -> PathBuf {
|
fn images_dir() -> PathBuf {
|
||||||
glib::user_data_dir()
|
glib::user_cache_dir()
|
||||||
.join("net.jeena.FeedTheMonkey")
|
.join("net.jeena.FeedTheMonkey")
|
||||||
.join("images")
|
.join("images")
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue