From 8b857e9c8a044d761f20393b4689966111641046 Mon Sep 17 00:00:00 2001 From: Zach Gollwitzer Date: Wed, 7 May 2025 16:51:11 -0400 Subject: [PATCH] Notify parent sync in ensure block --- app/models/sync.rb | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/app/models/sync.rb b/app/models/sync.rb index da7b1a5c..afd768ae 100644 --- a/app/models/sync.rb +++ b/app/models/sync.rb @@ -24,18 +24,19 @@ class Sync < ApplicationRecord complete! unless has_pending_child_syncs? - Rails.logger.info("Sync completed, starting post-sync") - - syncable.post_sync(self) unless has_pending_child_syncs? - - if has_parent? - notify_parent_of_completion! + unless has_pending_child_syncs? + Rails.logger.info("Sync completed, starting post-sync") + syncable.post_sync(self) + Rails.logger.info("Post-sync completed") end - - Rails.logger.info("Post-sync completed") rescue StandardError => error fail! error raise error if Rails.env.development? + ensure + if has_parent? + Rails.logger.info("notifying parent sync id=#{parent_id} of completion") + notify_parent_of_completion! + end end end end