ソースを参照

wallet: fix paths storing DBs to use ~/.local/share/darkfi/wallet/, and cache dirs to use ~/.cache/darkfi/wallet/

darkfi 1 年間 前
コミット
7b4aea3f2b

+ 7 - 3
bin/darkwallet/src/app/schema/mod.rs

@@ -77,10 +77,10 @@ mod desktop_paths {
     pub const BG_PATH: &str = "assets/bg.png";
 
     pub fn get_chatdb_path() -> PathBuf {
-        dirs::cache_dir().unwrap().join("darkfi/chatdb")
+        dirs::data_local_dir().unwrap().join("darkfi/wallet/chatdb")
     }
     pub fn get_first_time_filename() -> PathBuf {
-        dirs::cache_dir().unwrap().join("darkfi/first_time")
+        dirs::cache_dir().unwrap().join("darkfi/wallet/first_time")
     }
 }
 
@@ -237,7 +237,11 @@ pub async fn make(app: &App, window: SceneNodePtr) {
 
     let is_first_time = !get_first_time_filename().exists();
     if is_first_time {
-        let _ = File::create(get_first_time_filename());
+        let filename = get_first_time_filename();
+        if let Some(parent) = filename.parent() {
+            let _ = fs::create_dir_all(parent);
+        }
+        let _ = File::create(filename);
     }
 
     let chatdb_path = get_chatdb_path();

+ 3 - 2
bin/darkwallet/src/gfx/mod.rs

@@ -133,7 +133,7 @@ impl RenderApi {
         gfx_texture_id
     }
 
-    pub fn new_texture<F>(
+    pub fn new_texture<F, S>(
         &self,
         width: u16,
         height: u16,
@@ -141,7 +141,8 @@ impl RenderApi {
         make_debug: F,
     ) -> ManagedTexturePtr
     where
-        F: Fn() -> String,
+        F: Fn() -> S,
+        S: Into<String>,
     {
         let debug = if DEBUG_RESRC { make_debug().into() } else { String::new() };
         Arc::new(ManagedTexture {

+ 1 - 1
bin/darkwallet/src/plugin/darkirc.rs

@@ -58,7 +58,7 @@ fn get_evgrdb_path() -> PathBuf {
 }
 #[cfg(not(target_os = "android"))]
 fn get_evgrdb_path() -> PathBuf {
-    dirs::cache_dir().unwrap().join("darkfi/evgr")
+    dirs::data_local_dir().unwrap().join("darkfi/evgr")
 }
 
 #[cfg(target_os = "android")]

+ 3 - 2
bin/darkwallet/src/text/atlas.rs

@@ -135,9 +135,10 @@ impl<'a> Atlas<'a> {
     /// Each glyph is given a sub-rect within the texture, accessible by calling
     /// `rendered_atlas.fetch_uv(my_glyph_id)`.
     /// The texture ID is a struct member: `rendered_atlas.texture_id`.
-    pub fn make<F>(self, debug_info: F) -> RenderedAtlas
+    pub fn make<F, S>(self, debug_info: F) -> RenderedAtlas
     where
-        F: Fn() -> String,
+        F: Fn() -> S,
+        S: Into<String>,
     {
         //if self.glyph_ids.is_empty() {
         //    return Err(Error::AtlasIsEmpty);