Count updates/additions correctly. Add fields correctly. Various other fixes.
This commit is contained in:
parent
dade32145e
commit
06f09c0486
1 changed files with 26 additions and 16 deletions
|
|
@ -95,7 +95,7 @@ namespace :debshots do
|
||||||
if db_package
|
if db_package
|
||||||
Rails.logger.info "Removing blacklisted package '#{package[:Package]}' from database"
|
Rails.logger.info "Removing blacklisted package '#{package[:Package]}' from database"
|
||||||
db_package.destroy
|
db_package.destroy
|
||||||
stats_removed +=1
|
stats_removed += 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -110,8 +110,8 @@ namespace :debshots do
|
||||||
end
|
end
|
||||||
|
|
||||||
# Rails.logger.debug "Found in database: #{db_package}"
|
# Rails.logger.debug "Found in database: #{db_package}"
|
||||||
update_data(package, db_package)
|
data_has_changed = update_data(package, db_package)
|
||||||
stats_updated += 1
|
stats_updated += 1 if data_has_changed
|
||||||
end # package.each
|
end # package.each
|
||||||
|
|
||||||
end # architectures.each
|
end # architectures.each
|
||||||
|
|
@ -220,9 +220,10 @@ namespace :debshots do
|
||||||
end # namespace
|
end # namespace
|
||||||
|
|
||||||
# Update the information about a package in the database
|
# Update the information about a package in the database
|
||||||
|
# package: Information about new package (parsed from remote source)
|
||||||
|
# db_package: Information that currently exists in the database
|
||||||
def update_data(package, db_package)
|
def update_data(package, db_package)
|
||||||
Rails.logger.debug "New information: #{package.to_yaml}"
|
Rails.logger.debug "New information: #{package.inspect}"
|
||||||
Rails.logger.debug "Database information: #{db_package.to_yaml}"
|
|
||||||
|
|
||||||
# Check if the version changed
|
# Check if the version changed
|
||||||
# Only the actual upstream software version (e.g. 1.2) but not the package
|
# Only the actual upstream software version (e.g. 1.2) but not the package
|
||||||
|
|
@ -233,20 +234,29 @@ def update_data(package, db_package)
|
||||||
Rails.logger.fatal "Could not parse version string: #{package[:Version]}"
|
Rails.logger.fatal "Could not parse version string: #{package[:Version]}"
|
||||||
end
|
end
|
||||||
|
|
||||||
if new_version != package[:Version]
|
Rails.logger.debug "Comparing package version: old=#{db_package.version} new=#{new_version}"
|
||||||
Rails.logger.debug "- Version changed: #{db_package.version} -> #{new_version}"
|
if new_version == db_package.version
|
||||||
db_package.version = new_version
|
return false # data has not changed
|
||||||
db_package.description = package[:Description]
|
|
||||||
db_package.homepage = package[:Homepage]
|
|
||||||
db_package.section = package[:Section]
|
|
||||||
db_package.origin = package[:Origin]
|
|
||||||
package[:Maintainer]=~/^(.+) <(.+)?>/
|
|
||||||
db_package.maintainer = $1
|
|
||||||
db_package.maintainer_email = $2
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Rails.logger.info "New package version found. Updating details in database."
|
||||||
|
db_package.version = new_version
|
||||||
|
db_package.name = package[:Package] unless db_package.name # set the name for new packages
|
||||||
|
db_package.description = package[:Description][0..79]
|
||||||
|
db_package.homepage = package[:Homepage]
|
||||||
|
db_package.section = package[:Section]
|
||||||
|
db_package.origin = package[:Origin]
|
||||||
|
package[:Maintainer]=~/^(.+) <(.+)?>/
|
||||||
|
db_package.maintainer = $1
|
||||||
|
db_package.maintainer_email = $2
|
||||||
|
unless db_package.valid?
|
||||||
|
Rails.logger.error "New package information seems to be invalid: #{db_package.errors}"
|
||||||
|
exit false
|
||||||
|
end
|
||||||
db_package.save
|
db_package.save
|
||||||
Rails.logger.debug "Saved package data: #{db_package}"
|
Rails.logger.debug "Saved package data: #{db_package.inspect}"
|
||||||
|
exit if package[:Name]=='ceph-fuse'
|
||||||
|
return true # data has changed
|
||||||
end
|
end
|
||||||
|
|
||||||
# Check if a package name is blacklisted and should not be imported.
|
# Check if a package name is blacklisted and should not be imported.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue