Add forced full-site rendering
This commit is contained in:
@@ -144,6 +144,7 @@ impl BdsApp {
|
||||
)
|
||||
}
|
||||
Message::GenerateSite => self.queue_site_generation(None),
|
||||
Message::ForceGenerateSite => self.queue_forced_site_generation(),
|
||||
Message::RunMetadataDiff => {
|
||||
self.open_singleton_tab(TabType::MetadataDiff, "tabBar.metadataDiff");
|
||||
self.start_metadata_diff()
|
||||
@@ -311,19 +312,22 @@ impl BdsApp {
|
||||
Err(error) => {
|
||||
self.task_manager.fail(task_id, error.clone());
|
||||
self.task_manager.cancel_group(&group_id);
|
||||
if let Some(workflow) = self.site_generation_workflows.remove(&group_id)
|
||||
&& workflow.kind == SiteGenerationKind::Validation
|
||||
let workflow = self.site_generation_workflows.remove(&group_id);
|
||||
if workflow
|
||||
.as_ref()
|
||||
.is_some_and(|workflow| workflow.kind == SiteGenerationKind::Validation)
|
||||
{
|
||||
self.site_validation_state.is_applying = false;
|
||||
self.site_validation_state.error_message = Some(error.clone());
|
||||
}
|
||||
let operation = workflow.map_or_else(
|
||||
|| t(self.ui_locale, "engine.renderSiteGroup"),
|
||||
|workflow| workflow.group_name,
|
||||
);
|
||||
let message = tw(
|
||||
self.ui_locale,
|
||||
"common.operationFailed",
|
||||
&[
|
||||
("operation", &t(self.ui_locale, "engine.renderSiteGroup")),
|
||||
("error", &error),
|
||||
],
|
||||
&[("operation", &operation), ("error", &error)],
|
||||
);
|
||||
self.notify(ToastLevel::Error, &message);
|
||||
self.refresh_task_snapshots();
|
||||
|
||||
@@ -36,9 +36,23 @@ impl BdsApp {
|
||||
pub(super) fn queue_site_generation(
|
||||
&mut self,
|
||||
validation: Option<engine::validate_site::SiteValidationReport>,
|
||||
) -> Task<Message> {
|
||||
self.queue_site_generation_mode(validation, false)
|
||||
}
|
||||
|
||||
pub(super) fn queue_forced_site_generation(&mut self) -> Task<Message> {
|
||||
self.queue_site_generation_mode(None, true)
|
||||
}
|
||||
|
||||
fn queue_site_generation_mode(
|
||||
&mut self,
|
||||
validation: Option<engine::validate_site::SiteValidationReport>,
|
||||
force: bool,
|
||||
) -> Task<Message> {
|
||||
let kind = if validation.is_some() {
|
||||
SiteGenerationKind::Validation
|
||||
} else if force {
|
||||
SiteGenerationKind::Forced
|
||||
} else {
|
||||
SiteGenerationKind::Full
|
||||
};
|
||||
@@ -94,10 +108,10 @@ impl BdsApp {
|
||||
let group_id = format!("site-generation:{}", Uuid::new_v4());
|
||||
let group_name = t(
|
||||
self.ui_locale,
|
||||
if kind == SiteGenerationKind::Full {
|
||||
"engine.renderSiteGroup"
|
||||
} else {
|
||||
"engine.applyValidationGroup"
|
||||
match kind {
|
||||
SiteGenerationKind::Full => "engine.renderSiteGroup",
|
||||
SiteGenerationKind::Forced => "engine.forceRenderSiteGroup",
|
||||
SiteGenerationKind::Validation => "engine.applyValidationGroup",
|
||||
},
|
||||
);
|
||||
let mut render_task_ids = Vec::new();
|
||||
@@ -128,6 +142,7 @@ impl BdsApp {
|
||||
task_id,
|
||||
section,
|
||||
task_validation,
|
||||
force,
|
||||
locale,
|
||||
)
|
||||
})
|
||||
@@ -189,33 +204,46 @@ impl BdsApp {
|
||||
let output_dir = workflow.data_dir.join("html");
|
||||
let progress_manager = Arc::clone(&task_manager);
|
||||
let cancel_manager = Arc::clone(&task_manager);
|
||||
engine::generation::build_site_search_index_with_progress(
|
||||
db.conn(),
|
||||
&output_dir,
|
||||
&workflow.project_id,
|
||||
&metadata,
|
||||
move |current, total, path| {
|
||||
let progress = if total == 0 {
|
||||
1.0
|
||||
} else {
|
||||
current as f32 / total as f32
|
||||
};
|
||||
progress_manager.report_progress(
|
||||
task_id,
|
||||
Some(progress),
|
||||
Some(tw(
|
||||
locale,
|
||||
"engine.builtSearchFile",
|
||||
&[
|
||||
("path", path),
|
||||
("current", ¤t.to_string()),
|
||||
("total", &total.to_string()),
|
||||
],
|
||||
)),
|
||||
);
|
||||
},
|
||||
move || cancel_manager.is_cancelled(task_id),
|
||||
)
|
||||
let on_file = move |current: usize, total: usize, path: &str| {
|
||||
let progress = if total == 0 {
|
||||
1.0
|
||||
} else {
|
||||
current as f32 / total as f32
|
||||
};
|
||||
progress_manager.report_progress(
|
||||
task_id,
|
||||
Some(progress),
|
||||
Some(tw(
|
||||
locale,
|
||||
"engine.builtSearchFile",
|
||||
&[
|
||||
("path", path),
|
||||
("current", ¤t.to_string()),
|
||||
("total", &total.to_string()),
|
||||
],
|
||||
)),
|
||||
);
|
||||
};
|
||||
let is_cancelled = move || cancel_manager.is_cancelled(task_id);
|
||||
if workflow.kind == SiteGenerationKind::Forced {
|
||||
engine::generation::build_site_search_index_forced_with_progress(
|
||||
db.conn(),
|
||||
&output_dir,
|
||||
&workflow.project_id,
|
||||
&metadata,
|
||||
on_file,
|
||||
is_cancelled,
|
||||
)
|
||||
} else {
|
||||
engine::generation::build_site_search_index_with_progress(
|
||||
db.conn(),
|
||||
&output_dir,
|
||||
&workflow.project_id,
|
||||
&metadata,
|
||||
on_file,
|
||||
is_cancelled,
|
||||
)
|
||||
}
|
||||
.map_err(|error| error.to_string())
|
||||
})
|
||||
.await
|
||||
@@ -422,6 +450,7 @@ fn run_site_generation_section(
|
||||
task_id: TaskId,
|
||||
section: engine::generation::GenerationSection,
|
||||
validation: Option<engine::validate_site::SiteValidationReport>,
|
||||
force: bool,
|
||||
locale: UiLocale,
|
||||
) -> Result<engine::generation::GenerationReport, String> {
|
||||
if !task_manager.wait_until_runnable(task_id) {
|
||||
@@ -487,6 +516,16 @@ fn run_site_generation_section(
|
||||
on_page,
|
||||
is_cancelled,
|
||||
),
|
||||
None if force => engine::generation::render_site_section_forced_with_progress(
|
||||
db.conn(),
|
||||
&output_dir,
|
||||
&project_id,
|
||||
&metadata,
|
||||
&sources,
|
||||
section,
|
||||
on_page,
|
||||
is_cancelled,
|
||||
),
|
||||
None => engine::generation::render_site_section_with_progress(
|
||||
db.conn(),
|
||||
&output_dir,
|
||||
|
||||
Reference in New Issue
Block a user