From f075a75aeedfc88f4c9932d2d8922f3c60371fe9 Mon Sep 17 00:00:00 2001 From: Laurent Louf Date: Sat, 25 Jul 2020 01:20:08 +0200 Subject: [PATCH] Disable audio cache when there is an error trying to create a file --- core/src/cache.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/core/src/cache.rs b/core/src/cache.rs index 9ee0ae18..3a5385b4 100644 --- a/core/src/cache.rs +++ b/core/src/cache.rs @@ -86,8 +86,13 @@ impl Cache { mkdir_existing(path.parent().unwrap()).unwrap(); - let mut cache_file = File::create(path).unwrap(); - ::std::io::copy(contents, &mut cache_file).unwrap(); + let mut cache_file = File::create(path) + match cache_file { + Ok(file) => ::std::io::copy(contents, &mut file).unwrap(), + Err(error) => { + self.use_audio_cache = false + }, + }; } } }