feat(enhance): discard, tests against a mock ComfyUI, docs (#192)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Cameron CordesandClaude Opus 5.5 authored and cameron committed 2026-10-30 19:41:05 +00:00
1 parent 3a21761cfe
commit 97d9301a71
10 files changed
+1165 -48

No files matched your search

+21 -13
View File
@@ -180,11 +180,7 @@ fn resolve_file(
/// Library and relative path of an absolute file ComfyUI wrote. The job's own
/// library wins when roots overlap.
fn place_in_libraries(
libs: &[Library],
prefer: i32,
abs: &Path,
) -> Option<(i32, String)> {
fn place_in_libraries(libs: &[Library], prefer: i32, abs: &Path) -> Option<(i32, String)> {
let mut ordered: Vec<&Library> = libs.iter().collect();
ordered.sort_by_key(|l| l.id != prefer);
for lib in ordered {
@@ -292,10 +288,16 @@ pub async fn submit(
Ok(f) => f,
Err(r) => return r,
};
let reference = match body.reference_path.as_deref().filter(|p| !p.trim().is_empty()) {
let reference = match body
.reference_path
.as_deref()
.filter(|p| !p.trim().is_empty())
{
Some(p) => {
// The reference lives in the photo's own library.
let lib = app_state.library_by_id(photo.library_id).map(|l| l.name.clone());
let lib = app_state
.library_by_id(photo.library_id)
.map(|l| l.name.clone());
match resolve_file(&app_state, &exif_dao, p, lib.as_deref()) {
Ok(f) => Some(f),
Err(r) => return r,
@@ -304,7 +306,12 @@ pub async fn submit(
None => None,
};
match svc
.submit(&photo, &body.template, body.prompt.as_deref(), reference.as_ref())
.submit(
&photo,
&body.template,
body.prompt.as_deref(),
reference.as_ref(),
)
.await
{
Ok(job) => HttpResponse::Ok().json(job_view(&job)),
@@ -442,10 +449,8 @@ pub async fn approve(
let version_dao = app_state.version_dao.clone();
let exif_arc: Arc<Mutex<Box<dyn ExifDao>>> = exif_dao.clone().into_inner();
let (lib2, rel2, abs2) = (library.clone(), rel.clone(), abs.clone());
let ingested = web::block(move || {
ingest_saved(&lib2, &rel2, &abs2, &exif_arc, &version_dao)
})
.await;
let ingested =
web::block(move || ingest_saved(&lib2, &rel2, &abs2, &exif_arc, &version_dao)).await;
let hash = match ingested {
Ok(Some(h)) => h,
_ => {
@@ -461,7 +466,10 @@ pub async fn approve(
// Which version row did that become?
let entry = {
let mut dao = app_state.version_dao.lock().expect("Unable to lock VersionDao");
let mut dao = app_state
.version_dao
.lock()
.expect("Unable to lock VersionDao");
let original = match dao.get_link(&hash) {
Ok(Some(link)) => link.original_hash,
_ => job.original_hash.clone(),