diff options
author | Jason Colyer <jcolyer2007@gmail.com> | 2018-12-21 14:55:26 -0600 |
---|---|---|
committer | Jason Colyer <jcolyer2007@gmail.com> | 2019-01-16 08:29:40 -0600 |
commit | 6de60ef29575adb6480850cff32b37c820ad396b (patch) | |
tree | 67190e4f5df16a843fd03e9be902416487d8031a /lib/backup/files.rb | |
parent | aeb11d153e18a9a7adef30f49afa156fa6b0e3a5 (diff) | |
download | gitlab-ce-6de60ef29575adb6480850cff32b37c820ad396b.tar.gz |
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.
Diffstat (limited to 'lib/backup/files.rb')
-rw-r--r-- | lib/backup/files.rb | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/lib/backup/files.rb b/lib/backup/files.rb index 0032ae8f84b..31ef354ebb8 100644 --- a/lib/backup/files.rb +++ b/lib/backup/files.rb @@ -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 |