Skip to main content

restore_version

Function restore_version 

Source
pub async fn restore_version(
    pool: &PgPool,
    actor: &Actor,
    file_id: Uuid,
    version: i32,
) -> AppResult<FileRecord>
Expand description

Rollback: makes the content of an older version the newest version.

§Invariants

  • Permission: the file is visible to the actor (“not found” otherwise), its revision is checked out by the actor (409 otherwise) and editable (revisions::ensure_editable: in work, CAD editor of its group). An unknown version is “not found”, the current one a 400.
  • Locks: the revision row (revisions::lock) and the file row (FOR UPDATE).
  • Audit: file.restore.
  • Notifications / webhooks: none.
  • Data: history is kept: a new version is appended (copy of the old content and its references), no version is changed or removed.
  • Atomic: one transaction.