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 +4 -4
- data/lib/smart_s3_sync/file_target.rb +13 -24
- data/lib/smart_s3_sync/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dd521af6d2f61c2e97cdb862c4e9a30245763f6e
|
4
|
+
data.tar.gz: 3245d05505cc8d1cc34cf7d232e8dee78e8bd0c0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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(
|
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
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
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
|
-
|
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
|