rbsync 0.0.12 → 0.0.13
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.
- data/VERSION +1 -1
- data/lib/rbsync.rb +31 -14
- data/rbsync.gemspec +2 -2
- metadata +4 -4
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.13
|
data/lib/rbsync.rb
CHANGED
@@ -95,6 +95,7 @@ class RbSync
|
|
95
95
|
end
|
96
96
|
def FileUtils.mkdir_p(e)
|
97
97
|
`mkdir -p '#{e}'`
|
98
|
+
`touch '#{e}' -d '#{Time.now}'`
|
98
99
|
end
|
99
100
|
end
|
100
101
|
def initialize()
|
@@ -137,23 +138,29 @@ class RbSync
|
|
137
138
|
same_name_files = (dest_files & src_files)
|
138
139
|
same_name_files.reject!{|e|
|
139
140
|
#ファイルが同じモノは省く
|
141
|
+
puts "compare file bin. #{e}" if self.debug? || self.verbose?
|
142
|
+
$stdout.flush if self.debug?
|
140
143
|
FileUtils.cmp( File.expand_path(e,src) , File.expand_path(e,dest) )
|
141
144
|
} if options[:strict]
|
142
145
|
same_name_files.reject!{|e|
|
143
146
|
#ファイルサイズが同じモノを省く(全部比較する代替手段)
|
147
|
+
puts "size/mtime compare #{e}" if self.debug? || self.verbose?
|
144
148
|
File.size(File.expand_path(e,src)) == File.size( File.expand_path(e,dest))
|
145
149
|
#&& File.mtime(File.expand_path(e,src)) == File.mtime( File.expand_path(e,dest) )
|
146
150
|
} unless options[:strict]
|
147
151
|
if options[:update] then
|
148
152
|
same_name_files= same_name_files.select{|e|
|
153
|
+
puts "mtime is newer #{e}" if self.debug? || self.verbose?
|
149
154
|
(File.mtime(File.expand_path(e,src)) > File.mtime( File.expand_path(e,dest)))
|
150
155
|
}
|
151
156
|
end
|
152
157
|
if options[:overwrite] == false then
|
153
158
|
same_name_files= same_name_files.reject{|e|
|
159
|
+
puts "can over write? #{e}" if self.debug? || self.verbose?
|
154
160
|
(File.exists?(File.expand_path(e,src)) && File.exists?( File.expand_path(e,dest)))
|
155
161
|
}
|
156
162
|
end
|
163
|
+
$stdout.flush if self.debug?
|
157
164
|
files_not_in_dest = (src_files - dest_files)
|
158
165
|
#files
|
159
166
|
files =[]
|
@@ -343,26 +350,30 @@ class RbSync
|
|
343
350
|
self.copy_r(files)
|
344
351
|
end
|
345
352
|
def copy_r(files)
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
353
|
+
#
|
354
|
+
puts ("copy #{files.size} files") if(@conf[:progress])
|
355
|
+
$stdout.flush if(@conf[:progress])
|
356
|
+
|
350
357
|
files.each_with_index{|e,i|
|
351
358
|
#show
|
352
|
-
|
353
|
-
|
354
|
-
$stdout.flush
|
355
|
-
end
|
359
|
+
puts ("start #{i+1}/#{files.size}")if(@conf[:progress])
|
360
|
+
$stdout.flush if(@conf[:progress])
|
356
361
|
#main
|
362
|
+
tmp_name = "#{e[1]}.copy_tmp"
|
363
|
+
FileUtils.rm(tmp_name) if File.exists?(tmp_name)
|
357
364
|
copy_thread = Thread.start{
|
358
365
|
FileUtils.mkdir_p File.dirname(e[1]) unless File.exists?(File.dirname(e[1]))
|
359
|
-
tmp_name = "#{e[1]}.copy_tmp"
|
360
366
|
## todo copy file as stream for progress
|
361
|
-
|
362
|
-
|
367
|
+
begin
|
368
|
+
FileUtils.copy( e[0] , tmp_name ,{:preserve=>self.preserve?,:verbose=>self.verbose? } )
|
369
|
+
FileUtils.mv(tmp_name,e[1])
|
370
|
+
rescue Errno::EACCES => err
|
371
|
+
puts e[1];puts err
|
372
|
+
end
|
363
373
|
}
|
364
374
|
|
365
375
|
#progress of each file
|
376
|
+
puts "#{e[0]}" if self.verbose? || self.debug?
|
366
377
|
progress_thread = nil
|
367
378
|
if(@conf[:progress])
|
368
379
|
progress_thread = Thread.start{
|
@@ -372,8 +383,10 @@ class RbSync
|
|
372
383
|
dst_size = -1
|
373
384
|
bar.start("copying #{e[0]} \r\n to #{e[1]}")
|
374
385
|
cnt = 0
|
386
|
+
dst_name = tmp_name
|
375
387
|
while(src_size!=dst_size)
|
376
|
-
|
388
|
+
dst_name = e[1] if File.exists?(e[1]) and not File.exists?(tmp_name)
|
389
|
+
unless File.exists?(dst_name) then
|
377
390
|
cnt = cnt + 1
|
378
391
|
if cnt > 25 then
|
379
392
|
puts "copying #{e[1]} is terminated.\r\n timeout error"
|
@@ -384,13 +397,17 @@ class RbSync
|
|
384
397
|
next
|
385
398
|
end
|
386
399
|
src_size = File.size(e[0]).to_f
|
387
|
-
dst_size = File.size(
|
400
|
+
dst_size = File.size(dst_name).to_f
|
388
401
|
break if src_size == 0 # preven zero divide
|
389
402
|
# next if dst_size == 0 # preven zero divide
|
390
403
|
percent = dst_size/src_size*100
|
391
404
|
bar.progress(percent.to_int)
|
392
|
-
sleep 0.
|
405
|
+
sleep 0.6
|
393
406
|
end
|
407
|
+
src_size = File.size(e[0]).to_f
|
408
|
+
dst_size = File.size(e[1]).to_f
|
409
|
+
percent = dst_size/src_size*100
|
410
|
+
bar.progress(percent.to_int)
|
394
411
|
bar.end("done")
|
395
412
|
}
|
396
413
|
end
|
data/rbsync.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{rbsync}
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.13"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["takuya"]
|
12
|
-
s.date = %q{2011-07-
|
12
|
+
s.date = %q{2011-07-15}
|
13
13
|
s.description = %q{rbsync is sync file utility.this can sync directory even if filename differed.checking content insted.}
|
14
14
|
s.email = %q{takuya.1st@gmail}
|
15
15
|
s.extra_rdoc_files = [
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rbsync
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 5
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 13
|
10
|
+
version: 0.0.13
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- takuya
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-07-
|
18
|
+
date: 2011-07-15 00:00:00 +09:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|