Modified files.rb to handle tar error
Changed the run_pipeline! function to instead use Open3.pipeline_start In doing so, the code is able to grab the last STDERR. In the case where the error is the one from older tar versions (relating to ./), it will not raise a Backup::Error. All other instances of command failure will result in Backup::Error being raised.
This commit is contained in:
parent
aeb11d153e
commit
6de60ef295
1 changed files with 12 additions and 2 deletions
|
@ -71,8 +71,18 @@ module Backup
|
|||
end
|
||||
|
||||
def run_pipeline!(cmd_list, options = {})
|
||||
status_list = Open3.pipeline(*cmd_list, options)
|
||||
raise Backup::Error, 'Backup failed' unless status_list.compact.all?(&:success?)
|
||||
err_r, err_w = IO.pipe
|
||||
options[:err] = err_w
|
||||
status = []
|
||||
Open3.pipeline_start(*cmd_list, options) do |threads|
|
||||
err_w.close
|
||||
threads.collect { |t| status.push(t.value) }
|
||||
end
|
||||
unless status.compact.all?(&:success?)
|
||||
unless err_r.read =~ /^g?tar: \.: Cannot mkdir: No such file or directory/
|
||||
raise Backup::Error, 'Backup failed'
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue