Skip to content

Commit

Permalink
Add debugging information
Browse files Browse the repository at this point in the history
  • Loading branch information
sk274 committed Dec 4, 2019
1 parent bb04f8a commit b872a97
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
12 changes: 11 additions & 1 deletion lib/archival_storage_ingest/s3/s3_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class S3Manager
RETRY_INTERVAL = 60

attr_writer :s3
attr_accessor :logger

def s3
@s3 ||= Aws::S3::Resource.new
Expand All @@ -26,6 +27,12 @@ def initialize(s3_bucket, max_retry = MAX_RETRY)
@max_retry = max_retry
end

def log(msg)
return if logger.nil?

logger.info(msg)
end

def parse_s3_error(error)
"Code: #{error.code}\nContext: #{error.context}\nMessage: #{error.message}"
end
Expand All @@ -48,9 +55,12 @@ def upload_string(s3_key, data)
def list_object_keys(prefix)
resp = _list_object(prefix, nil)
object_keys = _list_keys(resp)
log("object keys: #{object_keys}")
while resp.is_truncated
resp = _list_object(prefix, resp.next_continuation_token)
object_keys.concat(_list_keys(resp))
next_keys = _list_keys(resp)
log("next keys: #{next_keys}")
object_keys.concat(next_keys)
end

object_keys
Expand Down
2 changes: 2 additions & 0 deletions lib/archival_storage_ingest/workers/fixity_worker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ def initialize(s3_manager = nil)
@s3_manager = s3_manager || ArchivalStorageIngest.configuration.s3_manager
@debug = ArchivalStorageIngest.configuration.debug
@logger = ArchivalStorageIngest.configuration.logger
@s3_manager.logger(@logger)
end

def worker_type
Expand Down Expand Up @@ -59,6 +60,7 @@ def generate_manifest(msg)
(sha, size, errors) = calculate_checksum(object_path, msg)
log_checksum_output(sha, size, errors) if debug
fixity_package.add_file_entry(filepath: object_path, sha1: sha, size: size)
break
end

manifest
Expand Down

0 comments on commit b872a97

Please sign in to comment.