bdsync 2.1.2 → 2.2.0
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/Gemfile.lock +1 -1
- data/lib/bdsync/core.rb +42 -12
- data/lib/bdsync/lfs.rb +4 -0
- data/lib/bdsync/sftp.rb +6 -0
- data/lib/bdsync/utils.rb +4 -0
- data/lib/bdsync/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1aeb789488a7670229fa4a2934989b606fa2ef25434ff47e43f3ac3e427dfd8a
|
4
|
+
data.tar.gz: e9ddef916d834bb0bd04b2bb390eba73563ba9e54780100bddf060a04b610650
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fc8b863ee0ad9ef4ba5f5a6e84e1fe5ee4d9aaf807448a25c7cad0d74450a201fdeb10676a325810b6550b1dfd4b8cd95e925a6f982ba75b2fad1e1d8eada2a0
|
7
|
+
data.tar.gz: 141a974e6ad5187e5509f769a7f5bd2b644b0bb908748cde83cb3e492a83bafab02d1d8ea746ff9d2692f9ebbbb8be1d84f5c197f37ed7fa77ac4e3abaec568d
|
data/Gemfile.lock
CHANGED
data/lib/bdsync/core.rb
CHANGED
@@ -173,8 +173,12 @@ module Bdsync
|
|
173
173
|
download_file local_path, remote_path
|
174
174
|
update_file_data relative_path, local_path, remote.mtime
|
175
175
|
else
|
176
|
-
|
177
|
-
|
176
|
+
# compare file contents, conflict if not equal
|
177
|
+
if !is_same_contents local_path, remote_path
|
178
|
+
handle_local_conflict local_path
|
179
|
+
download_file local_path, remote_path
|
180
|
+
end
|
181
|
+
|
178
182
|
update_file_data relative_path, local_path, remote.mtime
|
179
183
|
end
|
180
184
|
when :directory
|
@@ -202,8 +206,12 @@ module Bdsync
|
|
202
206
|
remote = upload_file local_path, remote_path
|
203
207
|
update_file_data relative_path, local_path, remote.mtime
|
204
208
|
else
|
205
|
-
|
206
|
-
|
209
|
+
# compare file contents, conflict if not equal
|
210
|
+
if !is_same_contents local_path, remote_path
|
211
|
+
handle_remote_conflict remote_path
|
212
|
+
remote = upload_file local_path, remote_path
|
213
|
+
end
|
214
|
+
|
207
215
|
update_file_data relative_path, local_path, remote.mtime
|
208
216
|
end
|
209
217
|
when :directory
|
@@ -260,12 +268,20 @@ module Bdsync
|
|
260
268
|
update_file_data relative_path, local_path, remote.mtime
|
261
269
|
else
|
262
270
|
if File.mtime(local_path).to_i > remote.mtime
|
263
|
-
|
264
|
-
|
271
|
+
# compare file contents, conflict if not equal
|
272
|
+
if !is_same_contents local_path, remote_path
|
273
|
+
handle_remote_conflict remote_path
|
274
|
+
remote = upload_file local_path, remote_path
|
275
|
+
end
|
276
|
+
|
265
277
|
update_file_data relative_path, local_path, remote.mtime
|
266
278
|
else
|
267
|
-
|
268
|
-
|
279
|
+
# compare file contents, conflict if not equal
|
280
|
+
if !is_same_contents local_path, remote_path
|
281
|
+
handle_local_conflict local_path
|
282
|
+
download_file local_path, remote_path
|
283
|
+
end
|
284
|
+
|
269
285
|
update_file_data relative_path, local_path, remote.mtime
|
270
286
|
end
|
271
287
|
end
|
@@ -339,12 +355,20 @@ module Bdsync
|
|
339
355
|
update_file_data relative_path, local_path, remote.mtime
|
340
356
|
else
|
341
357
|
if File.mtime(local_path).to_i > remote.mtime
|
342
|
-
|
343
|
-
|
358
|
+
# compare file contents, conflict if not equal
|
359
|
+
if !is_same_contents local_path, remote_path
|
360
|
+
handle_remote_conflict remote_path
|
361
|
+
remote = upload_file local_path, remote_path
|
362
|
+
end
|
363
|
+
|
344
364
|
update_file_data relative_path, local_path, remote.mtime
|
345
365
|
else
|
346
|
-
|
347
|
-
|
366
|
+
# compare file contents, conflict if not equal
|
367
|
+
if !is_same_contents local_path, remote_path
|
368
|
+
handle_local_conflict local_path
|
369
|
+
download_file local_path, remote_path
|
370
|
+
end
|
371
|
+
|
348
372
|
update_file_data relative_path, local_path, remote.mtime
|
349
373
|
end
|
350
374
|
end
|
@@ -437,5 +461,11 @@ module Bdsync
|
|
437
461
|
def local_ensure_parent path
|
438
462
|
local_ensure_dir File.dirname path
|
439
463
|
end
|
464
|
+
|
465
|
+
def is_same_contents local_path, remote_path
|
466
|
+
local_file_md5 = Utils.file_md5 local_path
|
467
|
+
remote_file_md5 = get_remote_file_md5 remote_path
|
468
|
+
local_file_md5 == remote_file_md5
|
469
|
+
end
|
440
470
|
end
|
441
471
|
end
|
data/lib/bdsync/lfs.rb
CHANGED
data/lib/bdsync/sftp.rb
CHANGED
@@ -82,5 +82,11 @@ module Bdsync
|
|
82
82
|
def remote_ensure_parent path
|
83
83
|
remote_ensure_dir File.dirname path
|
84
84
|
end
|
85
|
+
|
86
|
+
def get_remote_file_md5 remote_path
|
87
|
+
puts "#{Utils.caller_info 1} sftp.session.exec! md5sum #{remote_path}".white
|
88
|
+
res = @sftp.session.exec! "md5sum #{remote_path}"
|
89
|
+
res.split[0]
|
90
|
+
end
|
85
91
|
end
|
86
92
|
end
|
data/lib/bdsync/utils.rb
CHANGED
@@ -22,6 +22,10 @@ module Bdsync
|
|
22
22
|
Digest::MD5.hexdigest(s)
|
23
23
|
end
|
24
24
|
|
25
|
+
def self.file_md5 file_path
|
26
|
+
Digest::MD5.file(file_path).hexdigest
|
27
|
+
end
|
28
|
+
|
25
29
|
def self.caller_info level
|
26
30
|
info = caller[level].match(%r{([^/]+):(\d+):in `(.+)'})
|
27
31
|
"#{info.captures[0]}:#{info.captures[1]} - #{info.captures[2]}"
|
data/lib/bdsync/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bdsync
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Xia Xiongjun
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-01-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: colorize
|