1
0
Fork 1
Spiegel von https://github.com/dani-garcia/vaultwarden.git synchronisiert 2024-06-28 10:15:41 +02:00

more verbose permission denied error

be a bit more verbose about why a file could not be created when it is
caused by a permission denied error.
Dieser Commit ist enthalten in:
Stefan Melmuk 2022-10-12 01:07:12 +02:00
Ursprung 7532072d50
Commit 2dd5086916
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 817020C608FE9C09

Datei anzeigen

@ -1,7 +1,7 @@
//
// Web Headers and caching
//
use std::io::Cursor;
use std::io::{Cursor, ErrorKind};
use rocket::{
fairing::{Fairing, Info, Kind},
@ -311,7 +311,16 @@ pub fn file_exists(path: &str) -> bool {
pub fn write_file(path: &str, content: &[u8]) -> Result<(), crate::error::Error> {
use std::io::Write;
let mut f = File::create(path)?;
let mut f = match File::create(path) {
Ok(file) => file,
Err(e) => {
if e.kind() == ErrorKind::PermissionDenied {
error!("Can't create '{}': Permission denied", path);
}
return Err(From::from(e));
}
};
f.write_all(content)?;
f.flush()?;
Ok(())