23 lines
No EOL
739 B
Ruby
23 lines
No EOL
739 B
Ruby
namespace :debshots do
|
|
desc "Remove screenshot objects with non-existing images"
|
|
|
|
task :remove_broken_screenshots => :environment do
|
|
Rails.logger = Logger.new(STDOUT)
|
|
Rails.logger.level = Logger::INFO
|
|
#Rails.logger.level = Logger::DEBUG
|
|
|
|
base_path = Rails.root.join('public')
|
|
|
|
Rails.logger.info "Iterating over screenshots"
|
|
Screenshot.all.each do |screenshot|
|
|
path = File.join(base_path, screenshot.image_url(:large))
|
|
Rails.logger.debug "- #{screenshot.id} (package: #{screenshot.package.name}) (path: #{path})"
|
|
|
|
# Check that the file actually exists
|
|
unless File.file? path
|
|
Rails.logger.error "Screenshots not found at #{path}. Removing."
|
|
next
|
|
end
|
|
end
|
|
end
|
|
end |