diff options
| author | erdgeist <erdgeist@erdgeist.org> | 2026-07-23 19:45:47 +0200 |
|---|---|---|
| committer | erdgeist <erdgeist@erdgeist.org> | 2026-07-23 19:45:47 +0200 |
| commit | aedf5778aba87c4e8d036dde2a0b6ec79cf8b342 (patch) | |
| tree | 059a8954c332d0a7c3e48e44906a4104d4338007 /app/models | |
| parent | f993853db3e233f05a55de5ba2a87b77acf041aa (diff) | |
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.
Diffstat (limited to 'app/models')
| -rw-r--r-- | app/models/node.rb | 12 |
1 files changed, 6 insertions, 6 deletions
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 | |||
| 112 | end | 112 | end |
| 113 | end | 113 | end |
| 114 | 114 | ||
| 115 | # Creates or updates the autosave buffer from the given attributes. | 115 | def ensure_autosave! current_user |
| 116 | # Autosave rows are never associated to the node via node_id -- they | ||
| 117 | # must never appear in self.pages / the revisions list, which is the | ||
| 118 | # whole reason autosave exists as a separate, unversioned layer. | ||
| 119 | def autosave! attributes, current_user | ||
| 120 | assert_locked_by! current_user | 116 | assert_locked_by! current_user |
| 121 | |||
| 122 | unless self.autosave | 117 | unless self.autosave |
| 123 | self.autosave = Page.create!(:editor => current_user) | 118 | self.autosave = Page.create!(:editor => current_user) |
| 124 | self.autosave.clone_attributes_from(self.draft || self.head) if self.draft || self.head | 119 | self.autosave.clone_attributes_from(self.draft || self.head) if self.draft || self.head |
| 125 | self.save! | 120 | self.save! |
| 126 | end | 121 | end |
| 122 | self.autosave | ||
| 123 | end | ||
| 124 | |||
| 125 | def autosave! attributes, current_user | ||
| 126 | ensure_autosave!(current_user) | ||
| 127 | self.autosave.assign_attributes(attributes) | 127 | self.autosave.assign_attributes(attributes) |
| 128 | self.autosave.save! | 128 | self.autosave.save! |
| 129 | self.autosave | 129 | self.autosave |
