six-rsync 0.7.0 → 0.7.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/Rakefile +1 -1
  2. data/lib/six/rsync.rb +1 -1
  3. data/lib/six/rsync/lib.rb +26 -34
  4. metadata +3 -3
data/Rakefile CHANGED
@@ -12,7 +12,7 @@ require 'rake/testtask'
12
12
 
13
13
  spec = Gem::Specification.new do |s|
14
14
  s.name = 'six-rsync'
15
- s.version = '0.7.0'
15
+ s.version = '0.7.1'
16
16
  s.has_rdoc = true
17
17
  s.extra_rdoc_files = ['README', 'LICENSE']
18
18
  s.summary = 'Your summary here'
data/lib/six/rsync.rb CHANGED
@@ -28,7 +28,7 @@ module Six
28
28
 
29
29
  module Rsync
30
30
  COMPONENT = 'six-rsync'
31
- VERSION = '0.7.0'
31
+ VERSION = '0.7.1'
32
32
  BASE_PATH = Dir.pwd
33
33
 
34
34
  case RUBY_PLATFORM
data/lib/six/rsync/lib.rb CHANGED
@@ -364,23 +364,15 @@ module Six
364
364
  opts[:force] = true
365
365
  end
366
366
 
367
- hosts = config[:hosts].clone
368
- host = hosts.sample
367
+ hosts = h_hosts
369
368
 
370
369
  man = false
371
370
  man = true if !opts[:include].nil? && !opts[:include].empty?
372
371
  if opts[:force] && !man
373
372
  done = false
374
- b, i = false, 0
375
- #verbose = @verbose
376
- #@verbose = false
377
- until hosts.empty? || done do
378
- i += 1
373
+ hosts.each_with_index do |host, i|
379
374
  # FIXME: Nasty
380
- host = hosts.sample if b
381
- b = true
382
- hosts -= [host]
383
- @logger.info "Trying #{i}/#{config[:hosts].size}: #{host}"
375
+ @logger.info "Trying #{i + 1}/#{config[:hosts].size}: #{host}"
384
376
  begin
385
377
  arr_opts = []
386
378
  arr_opts << PARAMS
@@ -391,6 +383,7 @@ module Six
391
383
  command(cmd, arr_opts)
392
384
  load_repos(:remote)
393
385
  done = true
386
+ break
394
387
  rescue => e
395
388
  @logger.debug "#{e.class}: #{e.message} #{e.backtrace.join("\n")}"
396
389
  end
@@ -414,27 +407,31 @@ module Six
414
407
  save_repos
415
408
 
416
409
  # fetch latest sums and only update when changed
417
- compare_sums(true, host)
410
+ compare_sums(true)
411
+ end
412
+ end
413
+
414
+ def h_hosts(host = nil)
415
+ hosts = config[:hosts].clone
416
+ unless host.nil?
417
+ hosts -= [host]
418
+ hosts = hosts.insert(0, host)
418
419
  end
420
+ hosts
419
421
  end
420
422
 
421
- def compare_sums(online = true, host = config[:hosts].sample)
423
+ def compare_sums(online = true, host = nil)
422
424
  load_repos(:local)
423
425
  done = false
424
426
 
427
+ hosts = h_hosts(host)
428
+
425
429
  if online
426
- hosts = config[:hosts].clone
427
- b, i = false, 0
428
430
  verbose = @verbose
429
431
  @verbose = false
430
432
 
431
- until hosts.empty? || done do
432
- i += 1
433
- # FIXME: Nasty
434
- host = hosts.sample if b
435
- b = true
436
- hosts -= [host]
437
- @logger.info "Trying #{i}/#{config[:hosts].size}: #{host}"
433
+ hosts.each_with_index do |host, i|
434
+ @logger.info "Trying #{i + 1}/#{config[:hosts].size}: #{host}"
438
435
 
439
436
  begin
440
437
  FileUtils.cp(pack_path(".repository.yml"), rsync_path(".repository-pack.yml")) if File.exists?(pack_path(".repository.yml"))
@@ -446,6 +443,7 @@ module Six
446
443
  raise RsyncError
447
444
  end
448
445
  done = true
446
+ break
449
447
  rescue => e
450
448
  @logger.debug "#{e.class} #{e.message}: #{e.backtrace.join("\n")}"
451
449
  FileUtils.cp(rsync_path(".repository-pack.yml"), pack_path(".repository.yml")) if File.exists?(rsync_path(".repository-pack.yml"))
@@ -493,6 +491,8 @@ module Six
493
491
  end
494
492
  end
495
493
 
494
+ hosts = h_hosts(host)
495
+
496
496
  if mismatch.size > 0
497
497
  case typ
498
498
  when :pack
@@ -501,19 +501,10 @@ module Six
501
501
 
502
502
  ## Pack
503
503
  if online
504
- hosts = config[:hosts].clone
505
- host = hosts.sample unless host
506
- b, i = false, 0
507
- until hosts.empty? || done do
508
- i += 1
509
- # FIXME: Nasty
510
- if b
511
- host = hosts.sample
512
- @logger.info "Trying #{i}/#{config[:hosts].size}: #{host}"
513
- end
504
+ hosts.each_with_index do |host, i|
505
+ @logger.info "Trying #{i + 1}/#{config[:hosts].size}: #{host}"
506
+
514
507
  slist = nil
515
- b = true
516
- hosts -= [host]
517
508
 
518
509
  # TODO: Progress bar
519
510
  arr_opts = []
@@ -539,6 +530,7 @@ module Six
539
530
  command('', arr_opts)
540
531
 
541
532
  done = true
533
+ break
542
534
  rescue => e
543
535
  @logger.debug "ERROR: #{e.class} #{e.message} #{e.backtrace.join("\n")}"
544
536
  ensure
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 7
8
- - 0
9
- version: 0.7.0
8
+ - 1
9
+ version: 0.7.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - Sickboy
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-07-24 00:00:00 +02:00
17
+ date: 2010-07-26 00:00:00 +02:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency