Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
23 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |