s3sync 2.0.1 → 2.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/s3sync/config.rb +1 -1
- data/lib/s3sync/sync.rb +23 -15
- data/lib/s3sync/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8672f843e8dfe49d8332c6ed8212679926efdca1
|
4
|
+
data.tar.gz: 3142cb4b5b510800de393dd1a42033805f251eca
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a937fce93d46e724f586fce116a922bf0c6e993a893054b596963f68ac4c8480ecab166097862232c6df771aece1760c9e03dd462fac43bb34d52d953d1b1933
|
7
|
+
data.tar.gz: a17295b31fbc18d2d5e9a5476d0ba1bf3c54509bfd1c4425aea8d910bca15b4c84e2b1fe657d4ee447310750166d6d33d2871d7a24cdd88db1cf157b8271f105
|
data/lib/s3sync/config.rb
CHANGED
data/lib/s3sync/sync.rb
CHANGED
@@ -71,14 +71,18 @@ module S3Sync
|
|
71
71
|
class Node
|
72
72
|
include Comparable
|
73
73
|
|
74
|
+
SMALL_FILE = 50 * 1024 # 50.kilobytes
|
75
|
+
|
74
76
|
attr_accessor :base
|
75
77
|
attr_accessor :path
|
76
78
|
attr_accessor :size
|
79
|
+
attr_accessor :small_comparator
|
77
80
|
|
78
|
-
def initialize base, path, size
|
81
|
+
def initialize base, path, size, small_comparator = nil
|
79
82
|
@base = base
|
80
83
|
@path = path
|
81
84
|
@size = size
|
85
|
+
@small_comparator = small_comparator
|
82
86
|
end
|
83
87
|
|
84
88
|
def full
|
@@ -86,20 +90,21 @@ module S3Sync
|
|
86
90
|
end
|
87
91
|
|
88
92
|
def == other
|
89
|
-
|
90
|
-
end
|
91
|
-
|
92
|
-
def <=> other
|
93
|
-
if self.size < other.size
|
94
|
-
-1
|
95
|
-
elsif self.size > other.size
|
96
|
-
1
|
97
|
-
else
|
98
|
-
0
|
99
|
-
end
|
93
|
+
@size == other.size && compare_small_comparators(other)
|
100
94
|
end
|
101
95
|
|
102
96
|
alias eql? ==
|
97
|
+
|
98
|
+
private
|
99
|
+
|
100
|
+
# If files are small and both nodes have a comparator, we can call an extra
|
101
|
+
# provided block to verify equality. This allows
|
102
|
+
def compare_small_comparators(other)
|
103
|
+
return true if @size > SMALL_FILE || other.size > SMALL_FILE
|
104
|
+
return true if small_comparator.nil? || other.small_comparator.nil?
|
105
|
+
|
106
|
+
small_comparator.call == other.small_comparator.call
|
107
|
+
end
|
103
108
|
end
|
104
109
|
|
105
110
|
class LocalDirectory
|
@@ -136,7 +141,8 @@ module S3Sync
|
|
136
141
|
|
137
142
|
# We only need the relative path here
|
138
143
|
file_name = file.gsub(/^#{@source}\/?/, '').squeeze('/')
|
139
|
-
|
144
|
+
small_comparator = lambda { Digest::MD5.hexdigest File.read(file) }
|
145
|
+
node = Node.new(@source.squeeze('/'), file_name, st.size, small_comparator)
|
140
146
|
nodes[node.path] = node
|
141
147
|
end
|
142
148
|
|
@@ -153,7 +159,7 @@ module S3Sync
|
|
153
159
|
value2 = hash2.delete key
|
154
160
|
if value2.nil?
|
155
161
|
to_add_to_2 << value
|
156
|
-
elsif value2
|
162
|
+
elsif value2 == value
|
157
163
|
same << value
|
158
164
|
else
|
159
165
|
to_add_to_2 << value
|
@@ -297,7 +303,9 @@ module S3Sync
|
|
297
303
|
|
298
304
|
nodes = {}
|
299
305
|
@args.s3.buckets[location.bucket].objects.with_prefix(dir || "").to_a.collect do |obj|
|
300
|
-
|
306
|
+
# etag comes back with quotes (obj.etag.inspcet # => "\"abc...def\""
|
307
|
+
small_comparator = lambda { obj.etag[/[a-z0-9]+/] }
|
308
|
+
node = Node.new(location.path, obj.key, obj.content_length, small_comparator)
|
301
309
|
nodes[node.path] = node
|
302
310
|
end
|
303
311
|
return nodes
|
data/lib/s3sync/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: s3sync
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lincoln de Sousa
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-03-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk
|