Skip to main content

create_with_files

Function create_with_files 

Source
pub async fn create_with_files(
    pool: &PgPool,
    actor: &Actor,
    input: NewItem,
    uploads: &[Upload],
) -> AppResult<Revision>
Expand description

Creates an item and stores its first files in the new revision – one transaction, so there is never an item without the files it was created with. The revision stays checked out by the creator.

§Invariants

  • Permission / locks / audit / data: as create, then the new revision is locked (revisions::lock) and the files are stored like in files::attach (file.upload per file).
  • Notifications: none; the creator only starts watching the item.
  • Webhooks: simulation.result_added when the item is a simulation and result values are read from the uploaded files (see files::attach); otherwise none.
  • Atomic: one transaction; a refused upload leaves no item behind.