From af019b9a46331d368087b724bfe71b2e6acc0815 Mon Sep 17 00:00:00 2001 From: Dominik George <dominik.george@teckids.org> Date: Mon, 17 May 2021 18:35:33 +0200 Subject: [PATCH] [Cache] Add some more debugging and error logging --- src/cache.rs | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/cache.rs b/src/cache.rs index 9256531..dcdaeb3 100644 --- a/src/cache.rs +++ b/src/cache.rs @@ -273,7 +273,10 @@ impl UserInfo { // Determine XDG directories now let base_dirs = match BaseDirectories::with_prefix(BASE_NAME) { Ok(b) => b, - Err(e) => return Err(io::Error::new(io::ErrorKind::Other, e)) + Err(e) => { + error!("Could not determine XDG base directories: {}", e); + return Err(io::Error::new(io::ErrorKind::Other, e)); + } }; // Restore $HOME to original if we changed it earlier @@ -292,7 +295,10 @@ impl UserInfo { fn place_user_cache_file(&mut self, filename: String) -> Result<PathBuf, io::Error> { match self.get_user_xdg_base_directories() { Ok(b) => b.place_cache_file(filename), - Err(e) => Err(e) + Err(e) => { + error!("Error placing cache file {}: {}", filename, e); + Err(e) + } } } @@ -328,7 +334,7 @@ impl UserInfo { /// write the token to disk afterwards pub fn set_access_token(&mut self, token: BasicTokenResponse) -> Result<(), io::Error> { self.access_token = Some(token.clone()); - debug!("Saved token for in memory"); + debug!("Saved token in memory"); // Try to write user's token cache file // We need to ensure privileges were dropped successfully to avoid symlink attacks @@ -339,9 +345,15 @@ impl UserInfo { debug!("Storing token for in cache file"); save_json(path, token) }, - Err(e) => Err(e) + Err(e) => { + error!("Error getting cache path in user home: {}", e); + Err(e) + } }, - Err(e) => Err(e) + Err(e) => { + error!("Error dropping privileges to store token in user home: {}", e); + Err(e) + } }; self.restore_privileges(); return res; -- GitLab