summaryrefslogtreecommitdiff
path: root/app/models/node.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/node.rb')
-rw-r--r--app/models/node.rb10
1 files changed, 8 insertions, 2 deletions
diff --git a/app/models/node.rb b/app/models/node.rb
index 535d8f1..73eefd1 100644
--- a/app/models/node.rb
+++ b/app/models/node.rb
@@ -249,12 +249,18 @@ class Node < ApplicationRecord
249 self 249 self
250 end 250 end
251 251
252 # removes a draft and the lock if it is older than a day and still 252 # Releases whatever's stale and abandoned; never anything actively in
253 # identical to head 253 # use. Three independent cases share one rule -- nothing is touched
254 # unless it's been sitting untouched for over a day:
255 # - a lock held with no draft or autosave at all (the editor opened
256 # the page and never actually wrote anything)
257 # - a fresh autosave older than a day, never promoted to a draft
258 # - a draft older than a day that's still identical to head
254 def wipe_draft! 259 def wipe_draft!
255 return if self.autosave && self.autosave.updated_at > 1.day.ago 260 return if self.autosave && self.autosave.updated_at > 1.day.ago
256 261
257 unless self.draft 262 unless self.draft
263 return if self.autosave.nil? && self.locked? && self.updated_at > 1.day.ago
258 self.autosave&.destroy 264 self.autosave&.destroy
259 self.autosave_id = nil 265 self.autosave_id = nil
260 self.unlock! 266 self.unlock!