Class: Dor::CleanupService
- Inherits:
-
Object
- Object
- Dor::CleanupService
- Defined in:
- lib/dor/services/cleanup_service.rb
Overview
Remove all traces of the object’s data files from the workspace and export areas
Class Method Summary collapse
-
.cleanup(dor_item) ⇒ void
Delete all workspace and export entities for the druid.
- .cleanup_by_druid(druid) ⇒ Object
-
.cleanup_export(druid) ⇒ void
Remove copy of the data that was exported to preservation core.
-
.cleanup_workspace_content(druid, base) ⇒ void
Remove the object’s data files from the workspace area.
-
.remove_branch(pathname) ⇒ void
Remove the specified directory and all its children.
Class Method Details
.cleanup(dor_item) ⇒ void
This method returns an undefined value.
Returns Delete all workspace and export entities for the druid.
10 11 12 13 |
# File 'lib/dor/services/cleanup_service.rb', line 10 def self.cleanup(dor_item) druid = dor_item.druid cleanup_by_druid druid end |
.cleanup_by_druid(druid) ⇒ Object
15 16 17 18 19 |
# File 'lib/dor/services/cleanup_service.rb', line 15 def self.cleanup_by_druid(druid) cleanup_workspace_content(druid, Config.cleanup.local_workspace_root) cleanup_workspace_content(druid, Config.cleanup.local_assembly_root) cleanup_export(druid) end |
.cleanup_export(druid) ⇒ void
This method returns an undefined value.
Returns remove copy of the data that was exported to preservation core.
30 31 32 33 34 35 36 |
# File 'lib/dor/services/cleanup_service.rb', line 30 def self.cleanup_export(druid) id = druid.split(':').last bag_dir = File.join(Config.cleanup.local_export_home, id) self.remove_branch(bag_dir) tarfile = "#{bag_dir}.tar" self.remove_branch(tarfile) end |
.cleanup_workspace_content(druid, base) ⇒ void
This method returns an undefined value.
Returns remove the object’s data files from the workspace area.
24 25 26 |
# File 'lib/dor/services/cleanup_service.rb', line 24 def self.cleanup_workspace_content(druid, base) DruidTools::Druid.new(druid, base).prune! end |
.remove_branch(pathname) ⇒ void
This method returns an undefined value.
Returns Remove the specified directory and all its children.
40 41 42 43 |
# File 'lib/dor/services/cleanup_service.rb', line 40 def self.remove_branch(pathname) pathname = Pathname(pathname) if pathname.instance_of? String pathname.rmtree if pathname.exist? end |