Skip to content

Commit

Permalink
Skip Vm reconnect if already reconnected
Browse files Browse the repository at this point in the history
Applied changes from PR 17417
  • Loading branch information
slemrmartin committed Jun 12, 2018
1 parent afae58a commit 138e112
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,17 @@ module ManagerRefresh::InventoryCollection::Builder::Shared

inventory_objects_index.each_slice(100) do |batch|
batch_refs = batch.map(&:first)
relation.where(inventory_collection.manager_ref.first => batch_refs).each do |record|
relation.where(inventory_collection.manager_ref.first => batch_refs).order(:id => :asc).each do |record|
index = inventory_collection.object_index_with_keys(inventory_collection.manager_ref_to_cols, record)

# We need to delete the record from the inventory_objects_index
# and attributes_index, otherwise it would be sent for create.
inventory_object = inventory_objects_index.delete(index)
hash = attributes_index.delete(index)

# Skip if hash is blank, which can happen when having several archived entities with the same ref
next unless hash

record.assign_attributes(hash.except(:id, :type))
if !inventory_collection.check_changed? || record.changed?
record.save!
Expand Down

0 comments on commit 138e112

Please sign in to comment.