aboutsummaryrefslogtreecommitdiffstats
path: root/rust
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2022-02-16 20:02:17 -0800
committerBryan Newbold <bnewbold@robocracy.org>2022-03-09 16:13:03 -0800
commit97f6417a58c0ec3c897f9634d21e705b4e37d7b6 (patch)
tree767eb62e8d4efdc664b88da6ec122a4148377b6e /rust
parent4c7e0f2de21185fca25244204567a3351a3ebc0a (diff)
downloadfatcat-97f6417a58c0ec3c897f9634d21e705b4e37d7b6.tar.gz
fatcat-97f6417a58c0ec3c897f9634d21e705b4e37d7b6.zip
rust: don't set prev_rev on re-update if entity is created
This applies when re-editing any entity within an editgroup, when the entity does not yet exist other than the current editgroup. The current behavior was resulting in "updated" status, with "prev_rev" pointing to a revision which never existing in the catalog (aka, had never been merged).
Diffstat (limited to 'rust')
-rw-r--r--rust/src/entity_crud.rs9
1 files changed, 5 insertions, 4 deletions
diff --git a/rust/src/entity_crud.rs b/rust/src/entity_crud.rs
index f48246a5..e8f63d0c 100644
--- a/rust/src/entity_crud.rs
+++ b/rust/src/entity_crud.rs
@@ -410,10 +410,11 @@ macro_rules! generic_db_update {
fn db_update(&self, conn: &DbConn, edit_context: &EditContext, ident: FatcatId) -> Result<Self::EditRow> {
let current: Self::IdentRow = $ident_table::table.find(ident.to_uuid()).first(conn)?;
let no_redirect: Option<Uuid> = None;
- // Don't set prev_rev if current status is redirect
- let prev_rev = match current.redirect_id {
- Some(_) => None,
- None => current.rev_id,
+
+ // Don't set prev_rev if current state is 'redirect' or 'wip'
+ let prev_rev = match (current.redirect_id, current.is_live) {
+ (Some(_), _) | (_, false) => None,
+ (None, true) => current.rev_id,
};
if self.state.is_none() {