diff options
| author | Janito Vaqueiro Ferreira Filho <janito@mullvad.net> | 2019-02-27 17:36:04 +0000 |
|---|---|---|
| committer | Janito Vaqueiro Ferreira Filho <janito@mullvad.net> | 2019-04-03 16:46:17 +0000 |
| commit | 3af96f92cb3becaeb8490ed0b5b13099a57686fb (patch) | |
| tree | a4054efd4be60593b8edea346c0f776745d7ad8c | |
| parent | a6014898dae79925d3f4139bdb6b561a26f541e6 (diff) | |
| download | mullvadvpn-3af96f92cb3becaeb8490ed0b5b13099a57686fb.tar.xz mullvadvpn-3af96f92cb3becaeb8490ed0b5b13099a57686fb.zip | |
Implement cache path for Android
| -rw-r--r-- | mullvad-paths/src/cache.rs | 24 | ||||
| -rw-r--r-- | mullvad-paths/src/lib.rs | 2 |
2 files changed, 19 insertions, 7 deletions
diff --git a/mullvad-paths/src/cache.rs b/mullvad-paths/src/cache.rs index dd4307572c..50f11167f2 100644 --- a/mullvad-paths/src/cache.rs +++ b/mullvad-paths/src/cache.rs @@ -1,5 +1,8 @@ use crate::Result; -use std::{env, path::PathBuf}; +use std::{ + env, + path::{Path, PathBuf}, +}; /// Creates and returns the cache directory pointed to by `MULLVAD_CACHE_DIR`, or the default /// one if that variable is unset. @@ -15,14 +18,21 @@ fn get_cache_dir() -> Result<PathBuf> { } pub fn get_default_cache_dir() -> Result<PathBuf> { - let dir; - #[cfg(target_os = "linux")] + #[cfg(not(target_os = "android"))] { - dir = Ok(PathBuf::from("/var/cache")) + let dir; + #[cfg(target_os = "linux")] + { + dir = Ok(PathBuf::from("/var/cache")) + } + #[cfg(any(target_os = "macos", windows))] + { + dir = dirs::cache_dir().ok_or_else(|| crate::Error::FindDirError) + } + dir.map(|dir| dir.join(crate::PRODUCT_NAME)) } - #[cfg(any(target_os = "macos", windows))] + #[cfg(target_os = "android")] { - dir = dirs::cache_dir().ok_or(crate::Error::FindDirError) + Ok(Path::new(crate::APP_PATH).join("cache")) } - dir.map(|dir| dir.join(crate::PRODUCT_NAME)) } diff --git a/mullvad-paths/src/lib.rs b/mullvad-paths/src/lib.rs index 1d829e1145..57671e2c50 100644 --- a/mullvad-paths/src/lib.rs +++ b/mullvad-paths/src/lib.rs @@ -25,6 +25,8 @@ const PRODUCT_NAME: &str = "mullvad-vpn"; #[cfg(windows)] const PRODUCT_NAME: &str = "Mullvad VPN"; +#[cfg(target_os = "android")] +const APP_PATH: &str = "/data/data/net.mullvad.mullvadvpn"; #[cfg(windows)] fn get_allusersprofile_dir() -> Result<PathBuf> { |
