Class: Omnizip::Formats::Rar::ArchiveVerifier::VerificationResult

Inherits:
Object
  • Object
show all
Defined in:
lib/omnizip/formats/rar/archive_verifier.rb

Overview

Verification result

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeVerificationResult

Returns a new instance of VerificationResult.



17
18
19
20
21
22
23
24
25
26
27
# File 'lib/omnizip/formats/rar/archive_verifier.rb', line 17

def initialize
  @valid = true
  @files_total = 0
  @files_ok = 0
  @files_corrupted = 0
  @corrupted_files = []
  @recoverable = false
  @corrupt_blocks = []
  @recovery_available = false
  @errors = []
end

Instance Attribute Details

#corrupt_blocksObject

Returns the value of attribute corrupt_blocks.



13
14
15
# File 'lib/omnizip/formats/rar/archive_verifier.rb', line 13

def corrupt_blocks
  @corrupt_blocks
end

#corrupted_filesObject

Returns the value of attribute corrupted_files.



13
14
15
# File 'lib/omnizip/formats/rar/archive_verifier.rb', line 13

def corrupted_files
  @corrupted_files
end

#errorsObject

Returns the value of attribute errors.



13
14
15
# File 'lib/omnizip/formats/rar/archive_verifier.rb', line 13

def errors
  @errors
end

#files_corruptedObject

Returns the value of attribute files_corrupted.



13
14
15
# File 'lib/omnizip/formats/rar/archive_verifier.rb', line 13

def files_corrupted
  @files_corrupted
end

#files_okObject

Returns the value of attribute files_ok.



13
14
15
# File 'lib/omnizip/formats/rar/archive_verifier.rb', line 13

def files_ok
  @files_ok
end

#files_totalObject

Returns the value of attribute files_total.



13
14
15
# File 'lib/omnizip/formats/rar/archive_verifier.rb', line 13

def files_total
  @files_total
end

#recoverableObject

Returns the value of attribute recoverable.



13
14
15
# File 'lib/omnizip/formats/rar/archive_verifier.rb', line 13

def recoverable
  @recoverable
end

#recovery_availableObject

Returns the value of attribute recovery_available.



13
14
15
# File 'lib/omnizip/formats/rar/archive_verifier.rb', line 13

def recovery_available
  @recovery_available
end

#validObject

Returns the value of attribute valid.



13
14
15
# File 'lib/omnizip/formats/rar/archive_verifier.rb', line 13

def valid
  @valid
end

Instance Method Details

#can_repair?Boolean

Check if corruption can be repaired

Returns:

  • (Boolean)

    true if repairable



39
40
41
# File 'lib/omnizip/formats/rar/archive_verifier.rb', line 39

def can_repair?
  @recovery_available && @recoverable
end

#summaryString

Get summary string

Returns:

  • (String)

    Verification summary



46
47
48
49
50
51
52
53
54
# File 'lib/omnizip/formats/rar/archive_verifier.rb', line 46

def summary
  if valid?
    "Archive OK: #{@files_total} files verified"
  else
    msg = "Archive corrupted: #{@files_corrupted}/#{@files_total} files damaged"
    msg += " (repairable)" if can_repair?
    msg
  end
end

#valid?Boolean

Check if archive is valid

Returns:

  • (Boolean)

    true if valid



32
33
34
# File 'lib/omnizip/formats/rar/archive_verifier.rb', line 32

def valid?
  @valid && @files_corrupted.zero?
end