Class: Dor::ResetWorkspaceService

Inherits:
Object
  • Object
show all
Defined in:
lib/dor/services/reset_workspace_service.rb

Overview

Rename the druid trees at the end of the accessionWF in order to be cleaned/deleted later.

Class Method Summary collapse

Class Method Details

.reset_export_bag(druid, version, export_root) ⇒ Object


18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/dor/services/reset_workspace_service.rb', line 18

def self.reset_export_bag(druid, version, export_root)
  
  id = druid.split(':').last
  bag_dir = File.join(export_root, id)

  raise "The archived bag #{bag_dir}_v#{version} already existed." if  File.exists?("#{bag_dir}_v#{version}") 
  
  if File.exists?(bag_dir) 
    FileUtils.mv(bag_dir, "#{bag_dir}_v#{version}")
  end 
  
  if File.exists?("#{bag_dir}.tar") 
    FileUtils.mv("#{bag_dir}.tar", "#{bag_dir}_v#{version}.tar")
  end 
end

.reset_workspace_druid_tree(druid, version, workspace_root) ⇒ Object


6
7
8
9
10
11
12
13
14
15
16
# File 'lib/dor/services/reset_workspace_service.rb', line 6

def self.reset_workspace_druid_tree(druid, version, workspace_root)
  
  druid_tree_path = DruidTools::Druid.new(druid, workspace_root).pathname.to_s
  
  raise "The archived directory #{druid_tree_path}_v#{version} already existed." if  File.exists?("#{druid_tree_path}_v#{version}") 
  
  if File.exists?(druid_tree_path) 
    FileUtils.mv(druid_tree_path, "#{druid_tree_path}_v#{version}")
  end #Else is a truncated tree where we shouldn't do anything

end