ztk 1.4.2 → 1.4.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -185,6 +185,13 @@ module ZTK
185
185
  ssh and !ssh.closed? and ssh.close
186
186
  end
187
187
 
188
+ # The on_retry method we'll use with the RescueRetry class.
189
+ def on_retry(exception)
190
+ close
191
+ @ssh = nil
192
+ @sftp = nil
193
+ end
194
+
188
195
  # Launches an SSH console, replacing the current process with the console
189
196
  # process.
190
197
  #
@@ -41,7 +41,7 @@ module ZTK
41
41
  config.ui.logger.debug { "config=#{config.send(:table).inspect}" }
42
42
  config.ui.logger.info { "download(#{remote.inspect}, #{local.inspect})" }
43
43
 
44
- ZTK::RescueRetry.try(:tries => 3, :on => EOFError) do
44
+ ZTK::RescueRetry.try(:tries => 3, :on => EOFError, :on_retry => method(:on_retry)) do
45
45
  sftp.download!(remote.to_s, local.to_s) do |event, downloader, *args|
46
46
  case event
47
47
  when :open
@@ -58,7 +58,7 @@ module ZTK
58
58
 
59
59
  begin
60
60
  Timeout.timeout(options.timeout) do
61
- ZTK::RescueRetry.try(:tries => 3, :on => EOFError) do
61
+ ZTK::RescueRetry.try(:tries => 3, :on => EOFError, :on_retry => method(:on_retry)) do
62
62
 
63
63
  channel = ssh.open_channel do |chan|
64
64
  options.ui.logger.debug { "Channel opened." }
@@ -49,12 +49,15 @@ module ZTK
49
49
  ::File.open(tempfile, 'w') do |file|
50
50
  yield(file)
51
51
  end
52
- self.upload(tempfile.path, tempfile.path)
53
52
 
54
- self.exec(%(sudo mv -v #{tempfile.path} #{target}), :silence => true)
53
+ ZTK::RescueRetry.try(:tries => 2, :on_retry => method(:on_retry)) do
54
+ upload(tempfile.path, tempfile.path)
55
55
 
56
- self.exec(%(sudo chown -v #{chown} #{target}), :silence => true) if !chown.nil?
57
- self.exec(%(sudo chmod -v #{chmod} #{target}), :silence => true) if !chmod.nil?
56
+ exec(%(sudo mv -v #{tempfile.path} #{target}), :silence => true)
57
+
58
+ exec(%(sudo chown -v #{chown} #{target}), :silence => true) if !chown.nil?
59
+ exec(%(sudo chmod -v #{chmod} #{target}), :silence => true) if !chmod.nil?
60
+ end
58
61
 
59
62
  true
60
63
  end
@@ -41,7 +41,7 @@ module ZTK
41
41
  config.ui.logger.debug { "config=#{config.send(:table).inspect}" }
42
42
  config.ui.logger.info { "upload(#{local.inspect}, #{remote.inspect})" }
43
43
 
44
- ZTK::RescueRetry.try(:tries => 3, :on => EOFError) do
44
+ ZTK::RescueRetry.try(:tries => 3, :on => EOFError, :on_retry => method(:on_retry)) do
45
45
  sftp.upload!(local.to_s, remote.to_s) do |event, uploader, *args|
46
46
  case event
47
47
  when :open
@@ -21,6 +21,6 @@
21
21
  module ZTK
22
22
 
23
23
  # ZTK Version String
24
- VERSION = "1.4.2"
24
+ VERSION = "1.4.3"
25
25
 
26
26
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ztk
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.2
4
+ version: 1.4.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -263,7 +263,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
263
263
  version: '0'
264
264
  segments:
265
265
  - 0
266
- hash: -568917063704352555
266
+ hash: -1475474265463745848
267
267
  required_rubygems_version: !ruby/object:Gem::Requirement
268
268
  none: false
269
269
  requirements:
@@ -272,7 +272,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
272
272
  version: '0'
273
273
  segments:
274
274
  - 0
275
- hash: -568917063704352555
275
+ hash: -1475474265463745848
276
276
  requirements: []
277
277
  rubyforge_project:
278
278
  rubygems_version: 1.8.25