|
|
@ -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(())
|
|
|
|