Skip to content

Commit

Permalink
Merge 2532522 into 8e938d1
Browse files Browse the repository at this point in the history
  • Loading branch information
jcoyne committed Apr 26, 2019
2 parents 8e938d1 + 2532522 commit 44f9682
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions Gemfile
Expand Up @@ -29,6 +29,7 @@ gem 'rest-client'
# Pin net-http-persistent to avoid a problem with exhausting file handles when running under load
gem 'marc'
gem 'net-http-persistent', '~> 2.9'
gem 'progressbar' # for the cleaner rake task
gem 'uuidtools', '~> 2.1.4'

# DLSS/domain-specific dependencies
Expand Down
2 changes: 2 additions & 0 deletions Gemfile.lock
Expand Up @@ -275,6 +275,7 @@ GEM
parser (2.6.2.1)
ast (~> 2.4.0)
powerpack (0.1.2)
progressbar (1.10.0)
psych (3.1.0)
public_suffix (3.0.3)
puma (3.12.1)
Expand Down Expand Up @@ -463,6 +464,7 @@ DEPENDENCIES
marc
net-http-persistent (~> 2.9)
okcomputer
progressbar
puma (~> 3.0)
rack-console
rails (~> 5.2.0)
Expand Down
20 changes: 20 additions & 0 deletions lib/tasks/cleaner.rake
@@ -0,0 +1,20 @@
# frozen_string_literal: true

desc 'Delete all objects from the environment'
task delete_all_objects: :environment do
puts 'Are you sure you want to destroy EVERYTHING? Type "DELETE" to confirm.'
input = $stdin.gets.chomp
exit if input != 'DELETE'

total = ActiveFedora::Base.all.count
progressbar = ProgressBar.create(title: 'Items to delete', total: total)
ActiveFedora::Base.send(:connections).each do |conn|
conn.search(nil) do |object|
progressbar.increment
next if object.pid.start_with?('fedora-system:')
next unless DruidTools::Druid.valid?(object.pid)

Dor::CleanupService.nuke!(object.pid)
end
end
end

0 comments on commit 44f9682

Please sign in to comment.