filbunke 1.13.1 → 1.13.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YjVkNGQwMDVjOGIyNjI4NGI3YzE5MjljNDVlYmVhOGZlYzc0OTYzOA==
4
+ Y2RhNGVjMjMzZmFmZGFkOWQzMGE3OTJmYjlkZTg2NzU3NDYxNzNkNg==
5
5
  data.tar.gz: !binary |-
6
- NTU5N2RjNTU3NzUzYjEwOWUzMDk1ZjcwYjA2NmQ1ZGQ1NmQ5YjU4Yg==
6
+ NWIzOGJiNzIwNzEwYjMxMWQwMzFkNTI4NjYzYmIzOWFkYjRkZmZiNA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- YjU5Mzg0YjliMDBiOTE1ZGEyNzdlMTFlMGFjMTAwMDQ1ODVkZmE4NThlMGJi
10
- MzEwZGM2ZTRiN2U4YTBkOTU1ZmFhMjUxZDZkZGRhNmE4NjJjMDA5YzA4ZjIy
11
- MDhhOGM0ODdlMjUyNjBhNWNkNDUxNjZjYTExODc4MmEzNTU4ODU=
9
+ ZmViNTdlMWQxZjYwNGU3ZGFmODdkOWE3MzdhYzUxNTI0NDU4ZWVlMWYzNWI0
10
+ YzMyM2ZiM2M3Y2RkOTMzNWQ5MjQzM2UyZGJlYzkwNjRkZTc3YzcxZmFmMDNl
11
+ NmM3YjhhYTk1MjFkZmFjYzExODQzYmVjNzc5ZTE0NjQ2MjQ2OTY=
12
12
  data.tar.gz: !binary |-
13
- M2NiMmIwMmY3NTY3M2QzOWE1OWJkOGMwODYwYjUxMzFlNzNlOTY5MzljYzYx
14
- ZDJkZjg0YzMwZmI2M2FmMWE1NjE4MTJiOTc1ZDU0OTlhZjMyNDRlMThlYzYz
15
- ZTUxMDJiMDBmNjRkMTIwNjk1Y2U0NWU1YWZlYzMzOGNlNmQxM2M=
13
+ ZDk3OWY4MjMyZjE4ZDQ1N2ExZDFjYjgxMjQzYTFkZjg5MzFmMDU1MDQ3MWVi
14
+ MmJlZTU5MTI2OTQ3ZjY2NmY2MmMyZjA5MWMzOWU3MDBlNDQ5MGJjOGIyYjE5
15
+ NDYxM2EyNjNjZGE0OWE4NDA0NTgwODA5N2UyNjBlYzBlYTU3ODk=
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.13.1
1
+ 1.13.2
data/filbunke.gemspec CHANGED
@@ -2,11 +2,11 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: filbunke 1.13.1 ruby lib
5
+ # stub: filbunke 1.13.2 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "filbunke"
9
- s.version = "1.13.1"
9
+ s.version = "1.13.2"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib"]
@@ -256,13 +256,14 @@ module Filbunke
256
256
  end
257
257
 
258
258
  downloaded_file = nil
259
+ tmp_filename = "#{local_file_path}-#{(0...8).map { (65 + rand(26)).chr }.join}.tmp"
259
260
  async_request.on_headers do |response|
260
261
  if response.code != 200
261
262
  raise "Failed to fetch response(#{response.code}) for url '#{response.effective_url}' ---\n\t #{response.inspect}"
262
263
  end
263
264
  @logger.debug("Updating: #{local_file_path}")
264
265
  ::FileUtils.mkdir_p(::File.dirname(local_file_path))
265
- downloaded_file = ::File.new("#{local_file_path}.tmp", "wb")
266
+ downloaded_file = ::File.new(tmp_filename, "wb")
266
267
  end
267
268
 
268
269
  async_request.on_body do |chunk, response|
@@ -272,9 +273,11 @@ module Filbunke
272
273
  async_request.on_complete do |response|
273
274
  unless downloaded_file.nil?
274
275
  downloaded_file.close
275
- ::FileUtils.mv("#{local_file_path}.tmp", local_file_path)
276
+ end
277
+ if response.code == 200
278
+ ::FileUtils.mv(tmp_filename, local_file_path)
276
279
  else
277
- ::FileUtils.rm("#{local_file_path}.tmp") if ::File.exist?("#{local_file_path}.tmp")
280
+ ::FileUtils.rm(tmp_filename) if ::File.exist?(tmp_filename)
278
281
  end
279
282
  true
280
283
  end
@@ -320,22 +323,6 @@ module Filbunke
320
323
  end
321
324
  end
322
325
 
323
- def write_file!(file_path, contents)
324
-
325
- begin
326
- ::File.open("#{file_path}.tmp", 'w') do |file|
327
- file.write(contents)
328
- file.close
329
- end
330
- ::FileUtils.mv "#{file_path}.tmp", file_path
331
- return true
332
- rescue StandardError => e
333
- msg = ["#{e.class} - #{e.message}", *e.backtrace].join("\n\t")
334
- @logger.error "Failed to move file #{file_path}: #{msg}"
335
- return false
336
- end
337
- end
338
-
339
326
  def delete_file!(file_path)
340
327
  if ::File.exists?(file_path) then
341
328
  @logger.debug("Deleting: #{file_path}")
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: filbunke
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.13.1
4
+ version: 1.13.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wouter de Bie