mirror of
https://github.com/dani-garcia/vaultwarden.git
synced 2024-12-26 23:25:56 -05:00
Merge branch 'stefan0xC-check-data-folder-permissions'
This commit is contained in:
commit
d1ff136552
@ -303,6 +303,10 @@ async fn check_data_folder() {
|
|||||||
}
|
}
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
if !path.is_dir() {
|
||||||
|
error!("Data folder '{}' is not a directory.", data_folder);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
if is_running_in_docker()
|
if is_running_in_docker()
|
||||||
&& std::env::var("I_REALLY_WANT_VOLATILE_STORAGE").is_err()
|
&& std::env::var("I_REALLY_WANT_VOLATILE_STORAGE").is_err()
|
||||||
|
13
src/util.rs
13
src/util.rs
@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// Web Headers and caching
|
// Web Headers and caching
|
||||||
//
|
//
|
||||||
use std::io::Cursor;
|
use std::io::{Cursor, ErrorKind};
|
||||||
|
|
||||||
use rocket::{
|
use rocket::{
|
||||||
fairing::{Fairing, Info, Kind},
|
fairing::{Fairing, Info, Kind},
|
||||||
@ -326,7 +326,16 @@ pub fn file_exists(path: &str) -> bool {
|
|||||||
|
|
||||||
pub fn write_file(path: &str, content: &[u8]) -> Result<(), crate::error::Error> {
|
pub fn write_file(path: &str, content: &[u8]) -> Result<(), crate::error::Error> {
|
||||||
use std::io::Write;
|
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.write_all(content)?;
|
||||||
f.flush()?;
|
f.flush()?;
|
||||||
Ok(())
|
Ok(())
|
||||||
|
Loading…
Reference in New Issue
Block a user