From aedf5778aba87c4e8d036dde2a0b6ec79cf8b342 Mon Sep 17 00:00:00 2001 From: erdgeist Date: Thu, 23 Jul 2026 19:45:47 +0200 Subject: Keep in-editor asset curation off the head, layering it like every edit ensure_autosave! gives body keystrokes and asset curation one shared layer, so head is never mutated in place and every curation change surfaces in the publish delta. Stale rendered join ids are mapped across the clone via asset_id. Curation now requires holding the lock; a missing lock answers 423, matching the autosave endpoint. --- app/models/node.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'app/models') diff --git a/app/models/node.rb b/app/models/node.rb index 274b2f94..02502f6c 100644 --- a/app/models/node.rb +++ b/app/models/node.rb @@ -112,18 +112,18 @@ class Node < ApplicationRecord end end - # Creates or updates the autosave buffer from the given attributes. - # Autosave rows are never associated to the node via node_id -- they - # must never appear in self.pages / the revisions list, which is the - # whole reason autosave exists as a separate, unversioned layer. - def autosave! attributes, current_user + def ensure_autosave! current_user assert_locked_by! current_user - unless self.autosave self.autosave = Page.create!(:editor => current_user) self.autosave.clone_attributes_from(self.draft || self.head) if self.draft || self.head self.save! end + self.autosave + end + + def autosave! attributes, current_user + ensure_autosave!(current_user) self.autosave.assign_attributes(attributes) self.autosave.save! self.autosave -- cgit v1.3