From a782886f05191c1834404d777e74d00f9fa60f7e Mon Sep 17 00:00:00 2001 From: Michael Adler Date: Fri, 16 Jul 2021 09:42:17 +0200 Subject: [PATCH] Fix crash on read-only mimeapps.list Write permissions are not necessary when reading the file --- src/apps/user.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/apps/user.rs b/src/apps/user.rs index a778673..c22a75c 100644 --- a/src/apps/user.rs +++ b/src/apps/user.rs @@ -113,9 +113,10 @@ impl MimeApps { pub fn read() -> Result { let raw_conf = { let mut buf = String::new(); + let exists = std::path::Path::new(&Self::path()?).exists(); std::fs::OpenOptions::new() - .write(true) - .create(true) + .write(!exists) + .create(!exists) .read(true) .open(Self::path()?)? .read_to_string(&mut buf)?;