Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MiqGenericMountSession] Support @byte_count in #download_single #395

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/gems/pending/util/mount/miq_generic_mount_session.rb
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ def download_single(remote_file, local_file)
end

logger.info("#{log_header} Copying file [#{relpath}] to [#{local_file}]...")
IO.copy_stream(relpath, local_file)
IO.copy_stream(relpath, local_file, byte_count)
logger.info("#{log_header} Copying file [#{relpath}] to [#{local_file}] complete")
rescue => err
msg = "Downloading [#{remote_file}] to [#{local_file}], failed due to error: '#{err.message}'"
Expand Down
13 changes: 13 additions & 0 deletions spec/util/mount/miq_local_mount_session_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,5 +88,18 @@
expect(source_data.size).to eq(10.megabytes)
expect(source_data).to eq(File.read(source_path))
end

# Note, we are using `#download` in the spec, but really, this is a feature
# for `#download_single`. `#download` really doesn't make use of this
# directly.
it "respects the `byte_count` attribute" do
downloaded_data = StringIO.new

subject.instance_variable_set(:@byte_count, 42)
subject.download(downloaded_data, source_path)

expect(downloaded_data.string.size).to eq(42)
expect(downloaded_data.string).to eq("0" * 42)
end
end
end