Skip to content

Commit

Permalink
Resume FTP downloads by default
Browse files Browse the repository at this point in the history
  • Loading branch information
lmrodriguezr committed Jun 17, 2024
1 parent 5cc5596 commit c1bfed9
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ group :test do
gem 'codeclimate-test-reporter', '~> 1.0'
end

gem 'rake', '~> 12.0'
gem 'rake', '~> 13.0'
4 changes: 3 additions & 1 deletion lib/miga/cli/action/db.rb
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,9 @@ def check_digest(ver, file)
cli.say '' if cli[:pb]
dig = md5.hexdigest
cli.say "Observed: #{dig}"
raise 'Corrupt file, MD5 does not match' unless dig == ver[:MD5]
unless dig == ver[:MD5]
raise "Corrupt file, MD5 differs. Remove #{file} before trying again"
end
end

def version_size(ver)
Expand Down
4 changes: 3 additions & 1 deletion lib/miga/common/net.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ def remote_connection(host)
when 'ftp'
ftp = Net::FTP.new(uri.host)
ftp.passive = true
ftp.resume = true
ftp.login
ftp.chdir(uri.path) unless host.is_a?(URI)
ftp
Expand Down Expand Up @@ -87,7 +88,8 @@ def download_file_ftp(connection, file = nil, target = nil)
# Prepare download
FileUtils.mkdir_p(File.dirname(target)) if target
filesize = connection.size(file)
transferred = 0
transferred =
target && connection.resume && File.exist?(target) ? File.size(target) : 0

# Get in chunks of 1KiB
ret = ''
Expand Down
2 changes: 1 addition & 1 deletion lib/miga/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module MiGA
# - String indicating release status:
# - rc* release candidate, not released as gem
# - [0-9]+ stable release, released as gem
VERSION = [1.3, 15, 9].freeze
VERSION = [1.3, 15, 10].freeze

##
# Nickname for the current major.minor version.
Expand Down

0 comments on commit c1bfed9

Please sign in to comment.