diff options
Diffstat (limited to 'components/net/resource_thread.rs')
-rw-r--r-- | components/net/resource_thread.rs | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/components/net/resource_thread.rs b/components/net/resource_thread.rs index 43919362bfa..9c6a138da32 100644 --- a/components/net/resource_thread.rs +++ b/components/net/resource_thread.rs @@ -211,17 +211,17 @@ impl ResourceChannelManager { let _ = sender.send(()); } CoreResourceMsg::Exit => { - if let Some(ref profile_dir) = opts::get().profile_dir { + if let Some(ref config_dir) = opts::get().config_dir { match self.resource_manager.auth_cache.read() { - Ok(auth_cache) => write_json_to_file(&*auth_cache, profile_dir, "auth_cache.json"), + Ok(auth_cache) => write_json_to_file(&*auth_cache, config_dir, "auth_cache.json"), Err(_) => warn!("Error writing auth cache to disk"), } match self.resource_manager.cookie_jar.read() { - Ok(jar) => write_json_to_file(&*jar, profile_dir, "cookie_jar.json"), + Ok(jar) => write_json_to_file(&*jar, config_dir, "cookie_jar.json"), Err(_) => warn!("Error writing cookie jar to disk"), } match self.resource_manager.hsts_list.read() { - Ok(hsts) => write_json_to_file(&*hsts, profile_dir, "hsts_list.json"), + Ok(hsts) => write_json_to_file(&*hsts, config_dir, "hsts_list.json"), Err(_) => warn!("Error writing hsts list to disk"), } } @@ -233,9 +233,9 @@ impl ResourceChannelManager { } } -pub fn read_json_from_file<T: Decodable>(data: &mut T, profile_dir: &str, filename: &str) { +pub fn read_json_from_file<T: Decodable>(data: &mut T, config_dir: &str, filename: &str) { - let path = Path::new(profile_dir).join(filename); + let path = Path::new(config_dir).join(filename); let display = path.display(); let mut file = match File::open(&path) { @@ -261,13 +261,14 @@ pub fn read_json_from_file<T: Decodable>(data: &mut T, profile_dir: &str, filena } } -pub fn write_json_to_file<T: Encodable>(data: &T, profile_dir: &str, filename: &str) { +pub fn write_json_to_file<T: Encodable>(data: &T, config_dir: &str, filename: &str) { + let json_encoded: String; match json::encode(&data) { Ok(d) => json_encoded = d, Err(_) => return, } - let path = Path::new(profile_dir).join(filename); + let path = Path::new(config_dir).join(filename); let display = path.display(); let mut file = match File::create(&path) { @@ -391,10 +392,10 @@ impl CoreResourceManager { profiler_chan: ProfilerChan) -> CoreResourceManager { let mut auth_cache = AuthCache::new(); let mut cookie_jar = CookieStorage::new(); - if let Some(ref profile_dir) = opts::get().profile_dir { - read_json_from_file(&mut auth_cache, profile_dir, "auth_cache.json"); - read_json_from_file(&mut hsts_list, profile_dir, "hsts_list.json"); - read_json_from_file(&mut cookie_jar, profile_dir, "cookie_jar.json"); + if let Some(ref config_dir) = opts::get().config_dir { + read_json_from_file(&mut auth_cache, config_dir, "auth_cache.json"); + read_json_from_file(&mut hsts_list, config_dir, "hsts_list.json"); + read_json_from_file(&mut cookie_jar, config_dir, "cookie_jar.json"); } CoreResourceManager { user_agent: user_agent, |