Eliminate a registration race condition

Amolith created

Check whether we've actually deleted anything before proceeding with
registration; if we have not deleted anything, it means another customer
has registered that number before this one could.

Signed-off-by: Amolith <amolith@secluded.site>

Change summary

lib/tel_selections.rb | 1 +
1 file changed, 1 insertion(+)

Detailed changes

lib/tel_selections.rb 🔗

@@ -317,6 +317,7 @@ class TelSelections
 						tel, customer.customer_id, @bandwidth_account_id
 					)
 					db.exec_defer("DELETE FROM tel_inventory WHERE tel = $1", [tel])
+						.then { |r| raise unless r.cmd_tuples.positive? }
 				end
 			end
 		end