Skip to content
This repository was archived by the owner on Jan 19, 2026. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 59 additions & 34 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 11 additions & 2 deletions falconeri_common/src/models/output_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,16 +117,25 @@ pub struct NewOutputFile {
}

impl NewOutputFile {
/// Insert new output files into the database.
/// Insert new output files into the database. If a (job_id, uri) pair
/// already exists, return the existing record instead of erroring. This
/// makes the operation idempotent, which is important because the retry
/// logic may re-attempt an insert after a successful insert where the
/// response was lost.
#[tracing::instrument(skip(conn), level = "trace")]
pub fn insert_all(
output_files: &[Self],
conn: &mut PgConnection,
) -> Result<Vec<OutputFile>> {
use diesel::upsert::excluded;

let output_files = diesel::insert_into(output_files::table)
.values(output_files)
.on_conflict((output_files::job_id, output_files::uri))
.do_update()
.set(output_files::updated_at.eq(excluded(output_files::updated_at)))
.get_results::<OutputFile>(conn)
.context("error inserting datums")?;
.context("error inserting output files")?;
Ok(output_files)
}
}
Loading