smart_s3_sync 0.0.3 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cfb96961e17f6b5f47c93c3ad6987719746b8465
4
- data.tar.gz: 7d26d10a49ac44897d77eac3223857f20f89d8ec
3
+ metadata.gz: dd521af6d2f61c2e97cdb862c4e9a30245763f6e
4
+ data.tar.gz: 3245d05505cc8d1cc34cf7d232e8dee78e8bd0c0
5
5
  SHA512:
6
- metadata.gz: 10bd450070e40a6b8224a6453f29659b1cd76c3f1da16b686d4121e90366a52f07452cfed3fa38b8d84d21edcede0b227aca86050bc4c8ed04d590ba0729fecf
7
- data.tar.gz: 68313a3c35ed073772900647845c43e98a79912ad4cdf653da9fe6b5e177e19245079e9eb98d1e11cc6d40e4c1653e8bd712e28a71d6dfc3632cb2e38c7612aa
6
+ metadata.gz: 035b640a1f397c45fd805514126ddf1a9b7d40689bcd64746e1a681742d979a6787b44e08adc61c3b84d5caf06424c4941ce006e7a933fe2af2b3b9066023380
7
+ data.tar.gz: 4328af61ad2d9ab704631f9585e64eeea878a9191d4f267897dbeda46dc1e44a01ecd83a5fe46b4889458e03bd58b21a4ee08084240dab9f70e873ca15afd0d7
@@ -18,7 +18,6 @@ module SmartS3Sync
18
18
  # we don't add it to the list of destinations and instead
19
19
  # mark it as a local source.
20
20
  if File.exists?(file) && file_hash(file) == digest.to_s
21
- puts "#{file} is up to date"
22
21
  @local_source = file
23
22
  else
24
23
  destinations.push(file)
@@ -34,7 +33,7 @@ module SmartS3Sync
34
33
  if local_source.nil? # we prefer to not have to download
35
34
  copy_from_fog(fog_dir)
36
35
  else
37
- copy_from_local(source)
36
+ copy_from_local(local_source)
38
37
  end
39
38
  end
40
39
  end
@@ -81,32 +80,22 @@ module SmartS3Sync
81
80
  end
82
81
 
83
82
  def download(fog_dir)
84
- file = Tempfile.new(digest.to_s)
85
- done = 0
86
- now = Time.now.to_i
87
-
88
- fog_dir.files.get(remote_filename) do |chunk, left, total|
89
- if (chunk.bytes.size + left == total) # fog might restart in the middle
90
- file.rewind
91
- if done !=0
92
- puts " ERROR ... retrying"
93
- done = 0
83
+ dir = File.dirname(destinations[0])
84
+ FileUtils.mkdir_p(dir)
85
+ Tempfile.new(".#{digest}", dir).tap do |file|
86
+ fog_dir.files.get(remote_filename) do |chunk, left, total|
87
+ if (chunk.size + left == total) # fog might restart in the middle
88
+ file.rewind
89
+ if done !=0
90
+ puts " ERROR ... retrying"
91
+ done = 0
92
+ end
94
93
  end
95
- end
96
94
 
97
- file.write chunk
98
- (((1 - (left.to_f / total)) * 50).to_i - done).times do
99
- done += 1
100
- print "#"
101
- end
102
- if done == 50
103
- done = total / 1048576.to_f
95
+ file.write chunk
104
96
  end
97
+ file.close
105
98
  end
106
-
107
- puts " #{((done / [Time.now.to_i - now, 0.5].max) * 100).to_i / 100.0} MB/s"
108
- file.close
109
- file
110
99
  end
111
100
  end
112
101
  end
@@ -1,3 +1,3 @@
1
1
  module SmartS3Sync
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smart_s3_sync
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Rhoden