Skip to main content

run

Function run 

Source
pub async fn run(
    pool: &PgPool,
    actor: &Actor,
    table: &BomTable,
    filename: &str,
    options: &ImportOptions,
    source: Option<&Upload>,
) -> AppResult<ImportResult>
Expand description

Runs an import in one transaction. source (the STEP file, see step_file) is attached to a new top-level assembly.

ยงInvariants

  • Permission: editor role (403). With a target revision: visible, checked out by the actor (409 otherwise) and editable (revisions::ensure_editable). The project group must exist and be visible (400), not archived (400) and the actor a member (403). A table without importable rows is a 400.
  • Locks: the target revision (revisions::lock), each new revision it fills, the project group row (FOR SHARE) and the number counters of the new items.
  • Audit: item.create per new item, file.upload for the attached STEP file, bom.add per line, then import.bom on the root revision.
  • Notifications: none; the importer only starts watching new items.
  • Webhooks: none.
  • Atomic: one transaction (tests/import_atomicity.rs); a refused or failing import leaves no item, line, counter step or audit entry.