Skip to content

Commit

Permalink
[api] handle invalid double entries gracefully
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianschroeter committed Feb 10, 2015
1 parent 54337f7 commit 858d2e9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/api/app/models/binary_release.rb
Expand Up @@ -141,7 +141,9 @@ def self.update_binary_releases_via_json(repository, json, time = Time.now)
}
# check for existing entry
existing = oldlist.where(hash)
raise SaveError if existing.count > 1
Rails.logger.info "ERROR: multiple matches, cleaning up: #{existing.inspect}" if existing.count > 1
# double definition means broken DB entries
existing.offset(1).destroy_all

# compare with existing entry
if existing.count == 1
Expand Down
2 changes: 1 addition & 1 deletion src/api/test/unit/code_quality_test.rb
Expand Up @@ -68,7 +68,7 @@ def setup
BlackList = {
'ApplicationController#extract_ldap_user' => 116.66,
'AttributeController#attribute_definition' => 87.7,
'BinaryRelease::update_binary_releases_via_json' => 122.54,
'BinaryRelease::update_binary_releases_via_json' => 128.58,
'BranchPackage#find_packages_to_branch' => 234.73,
'BranchPackage#create_branch_packages' => 214.0,
'BranchPackage#determine_details_about_package_to_branch' => 124.62,
Expand Down

0 comments on commit 858d2e9

Please sign in to comment.