Переглянути джерело

Disable audio cache when there is an error trying to create a file

Laurent Louf 4 роки тому
батько
коміт
f075a75aee
1 змінених файлів з 7 додано та 2 видалено
  1. 7 2
      core/src/cache.rs

+ 7 - 2
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
+                },
+            };
         }
     }
 }