feat: make all export available by commands (#1547)

This commit is contained in:
Myriad-Dreamin 2025-03-20 16:18:13 +08:00 committed by GitHub
parent 1039e6f4fe
commit fadf85e68a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 229 additions and 26 deletions

View file

@ -458,11 +458,11 @@ impl ServerState {
}
if let Some(Some(path)) = open.then_some(res.as_ref()) {
log::info!("open with system default apps: {path:?}");
log::trace!("open with system default apps: {path:?}");
do_open(path).log_error("failed to open with system default apps");
}
log::info!("CompileActor: on export end: {path:?} as {res:?}");
log::trace!("CompileActor: on export end: {path:?} as {res:?}");
Ok(tinymist_query::CompilerQueryResponse::OnExport(res))
})
}

View file

@ -1,6 +1,7 @@
//! The actor that handles various document export, like PDF and SVG export.
use std::str::FromStr;
use std::sync::atomic::AtomicUsize;
use std::{path::PathBuf, sync::Arc};
use reflexo::ImmutPath;
@ -150,7 +151,11 @@ impl ExportTask {
bail!("ExportTask({task:?}): output path is a directory: {to:?}");
}
let to = to.with_extension(task.extension());
log::info!("ExportTask({task:?}): exporting {entry:?} to {to:?}");
static EXPORT_ID: AtomicUsize = AtomicUsize::new(0);
let export_id = EXPORT_ID.fetch_add(1, std::sync::atomic::Ordering::SeqCst);
log::info!("ExportTask({export_id}): exporting {entry:?} to {to:?}");
if let Some(e) = to.parent() {
if !e.exists() {
std::fs::create_dir_all(e).context("failed to create directory")?;
@ -312,7 +317,7 @@ impl ExportTask {
.await
.context("failed to export")?;
log::info!("ExportTask({task:?}): export complete");
log::info!("ExportTask({export_id}): export complete");
Ok(Some(to))
}
}