Class: Aws::S3::DirectoryUploader::FileProducer Private

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/aws-sdk-s3/directory_uploader.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

API:

  • private

Defined Under Namespace

Classes: UploadEntry

Constant Summary collapse

DEFAULT_QUEUE_SIZE =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

API:

  • private

100
DONE_MARKER =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

API:

  • private

:done

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ FileProducer

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of FileProducer.

API:

  • private



124
125
126
127
128
129
130
131
132
133
134
# File 'lib/aws-sdk-s3/directory_uploader.rb', line 124

def initialize(opts = {})
  @directory_uploader = opts[:directory_uploader]
  @source_dir = opts[:source_dir]
  @bucket = opts[:bucket]
  @s3_prefix = opts[:s3_prefix]
  @recursive = opts[:recursive]
  @follow_symlinks = opts[:follow_symlinks]
  @filter_callback = opts[:filter_callback]
  @request_callback = opts[:request_callback]
  @file_queue = SizedQueue.new(DEFAULT_QUEUE_SIZE)
end

Instance Method Details

#closeObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

API:

  • private



140
141
142
143
# File 'lib/aws-sdk-s3/directory_uploader.rb', line 140

def close
  @file_queue.close
  @file_queue.clear
end

#closed?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

API:

  • private



136
137
138
# File 'lib/aws-sdk-s3/directory_uploader.rb', line 136

def closed?
  @file_queue.closed?
end

#eachObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

API:

  • private



145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
# File 'lib/aws-sdk-s3/directory_uploader.rb', line 145

def each
  producer_thread = Thread.new do
    if @recursive
      find_recursively
    else
      find_directly
    end
    @file_queue << DONE_MARKER
  rescue ClosedQueueError
    # abort requested
  rescue StandardError => e
    # encountered a traversal error, we must abort immediately
    close
    raise DirectoryUploadError, "Directory traversal failed for '#{@source_dir}': #{e.message}"
  end

  while (file = @file_queue.shift) && file != DONE_MARKER
    yield file
  end
ensure
  producer_thread.value
end