Class: Robots::SdrRepo::SdrRecovery::RecoveryCleanup

Inherits:
Robots::SdrRepo::SdrRobot show all
Defined in:
lib/sdr_recovery/recovery_cleanup.rb

Overview

A robot for file cleanup after the object recovery

Instance Method Summary collapse

Methods inherited from Robots::SdrRepo::SdrRobot

#create_workflow_rows, #get_workflow_status, #get_workflow_xml, #process_item, #transmit, #update_workflow_error_status, #update_workflow_status

Constructor Details

#initialize(opts = {}) ⇒ RecoveryCleanup


16
17
18
# File 'lib/sdr_recovery/recovery_cleanup.rb', line 16

def initialize(opts = {})
  super(self.class.workflow_name, self.class.step_name, opts)
end

Instance Method Details

#cleanup_recovery_files(druid, recovery_path) ⇒ Boolean


39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/sdr_recovery/recovery_cleanup.rb', line 39

def cleanup_recovery_files(druid, recovery_path)
  # retry up to 3 times
  tries ||= 3
  recovery_path.rmtree
  return true
rescue StandardError => e
  if (tries -= 1) > 0
    retry
  else
    raise ItemError.new("Failed rmtree #{recovery_path} (3 attempts)")
  end
end

#perform(druid) ⇒ void


23
24
25
26
# File 'lib/sdr_recovery/recovery_cleanup.rb', line 23

def perform(druid)
  LyberCore::Log.debug("( #{__FILE__} : #{__LINE__} ) Enter perform")
  recovery_cleanup(druid)
end

#recovery_cleanup(druid) ⇒ Boolean


30
31
32
33
34
# File 'lib/sdr_recovery/recovery_cleanup.rb', line 30

def recovery_cleanup(druid)
  LyberCore::Log.debug("( #{__FILE__} : #{__LINE__} ) Enter recovery_cleanup")
  recovery_path = Pathname(Sdr::Config.sdr_recovery_home).join(druid.sub('druid:', ''))
  cleanup_recovery_files(druid, recovery_path) if recovery_path.exist?
end

#verification_files(druid) ⇒ Object


58
59
60
61
62
# File 'lib/sdr_recovery/recovery_cleanup.rb', line 58

def verification_files(druid)
  files = []
  files << Sdr::Config.sdr_recovery_home
  files
end

#verification_queries(druid) ⇒ Object


53
54
55
56
# File 'lib/sdr_recovery/recovery_cleanup.rb', line 53

def verification_queries(druid)
  queries = []
  queries
end