building now clears build dir
This commit is contained in:
+15
-1
@@ -241,7 +241,7 @@ impl FleenApp {
|
|||||||
for entry in root.join(dir).read_dir().unwrap() {
|
for entry in root.join(dir).read_dir().unwrap() {
|
||||||
let file = PathBuf::from(entry.unwrap().file_name());
|
let file = PathBuf::from(entry.unwrap().file_name());
|
||||||
sources.push(renderer::file_render(dir.join(&file), root)?);
|
sources.push(renderer::file_render(dir.join(&file), root)?);
|
||||||
if root.join(&dir).join(&file).is_dir() {
|
if root.join(dir).join(&file).is_dir() {
|
||||||
// root + dir + file is a child directory, so we want to recurse...
|
// root + dir + file is a child directory, so we want to recurse...
|
||||||
// into dir + file.
|
// into dir + file.
|
||||||
visit_dir(&dir.join(&file), root, sources)?
|
visit_dir(&dir.join(&file), root, sources)?
|
||||||
@@ -254,12 +254,26 @@ impl FleenApp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn build_site(&self, target: &Path) -> Result<(), FleenError> {
|
pub fn build_site(&self, target: &Path) -> Result<(), FleenError> {
|
||||||
|
// Ensure neither the target nor src dirs are ancestors of the other
|
||||||
if self.root.ancestors().any(|a| a == target) ||
|
if self.root.ancestors().any(|a| a == target) ||
|
||||||
target.ancestors().any(|a| a == self.root) {
|
target.ancestors().any(|a| a == self.root) {
|
||||||
return Err(TargetDir)
|
return Err(TargetDir)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Clear the target directory first:
|
||||||
|
for entry in fs::read_dir(target)? {
|
||||||
|
let entry = entry?;
|
||||||
|
if entry.file_type()?.is_dir() {
|
||||||
|
fs::remove_dir_all(entry.path())?
|
||||||
|
} else {
|
||||||
|
fs::remove_file(entry.path())?
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Decide which actions we need to do to build the site
|
||||||
let actions = self.compile()?;
|
let actions = self.compile()?;
|
||||||
|
|
||||||
|
// And then do them!
|
||||||
for action in actions.into_iter() {
|
for action in actions.into_iter() {
|
||||||
action.file_operation(&self.root, target)?;
|
action.file_operation(&self.root, target)?;
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -5,7 +5,7 @@ mod ui_ext;
|
|||||||
|
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
use std::time::{Duration, Instant};
|
use std::time::{Duration, Instant};
|
||||||
use eframe::egui::{Button, Context, Direction, Id, Layout, RichText};
|
use eframe::egui::{Button, Context, Id, RichText};
|
||||||
use eframe::{egui, Frame};
|
use eframe::{egui, Frame};
|
||||||
use egui_ltreeview::Action;
|
use egui_ltreeview::Action;
|
||||||
use tokio::task::JoinHandle;
|
use tokio::task::JoinHandle;
|
||||||
|
|||||||
+1
-1
@@ -39,7 +39,7 @@ fn serve_path(path: String, root: PathBuf) -> impl IntoResponse {
|
|||||||
// We were pointed at the raw contents of a file:
|
// We were pointed at the raw contents of a file:
|
||||||
Response::builder()
|
Response::builder()
|
||||||
.status(200)
|
.status(200)
|
||||||
.body(Body::from(fs::read(root.join(file)).unwrap_or(vec![]))).unwrap()
|
.body(Body::from(fs::read(root.join(file)).unwrap_or_default())).unwrap()
|
||||||
}
|
}
|
||||||
Ok(RenderOutput::NoOutput) |
|
Ok(RenderOutput::NoOutput) |
|
||||||
Ok(RenderOutput::Dir(_)) => {
|
Ok(RenderOutput::Dir(_)) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user