Class: Duracloud::FastSyncValidation

Inherits:
SyncValidation show all
Defined in:
lib/duracloud/fast_sync_validation.rb

Constant Summary

Constants inherited from SyncValidation

SyncValidation::CHANGED, SyncValidation::FOUND, SyncValidation::MANIFEST_CSV_OPTS, SyncValidation::MD5_CSV_OPTS, SyncValidation::MISSING, SyncValidation::TWO_SPACES

Instance Method Summary collapse

Methods inherited from SyncValidation

call, #call, #download_manifest, #in_work_dir, #recheck

Instance Method Details

#auditObject



9
10
11
12
13
14
15
16
# File 'lib/duracloud/fast_sync_validation.rb', line 9

def audit
  find_files
  if system("comm", "-23", find_filename, converted_manifest_filename, out: audit_filename)
    File.empty?(audit_filename) || recheck
  else
    raise Error, "Error comparing #{find_filename} with #{converted_manifest_filename}."
  end
end

#convert_manifestObject



4
5
6
7
# File 'lib/duracloud/fast_sync_validation.rb', line 4

def convert_manifest
  # content-id is the 2nd column of the manifest
  system("cut -f 2 #{manifest_filename} | sort", out: converted_manifest_filename)
end

#find_filesObject



18
19
20
21
22
23
24
# File 'lib/duracloud/fast_sync_validation.rb', line 18

def find_files
  # TODO handle exclude file?
  outfile = File.join(FileUtils.pwd, find_filename)
  # Using a separate command for sort so we get find results incrementally
  system("find -L . -type f | sed -e 's|^\./||'", chdir: content_dir, out: outfile) &&
    system("sort", "-o", find_filename, find_filename)
end