diff --git a/gems/gitlab-backup-cli/lib/gitlab/backup/cli/shell/pipeline.rb b/gems/gitlab-backup-cli/lib/gitlab/backup/cli/shell/pipeline.rb index 6a18c54ff59325d811228f682d55e102ac488def..8da4065b707ebabaeaaa3b4b8cf42a6158e783a4 100644 --- a/gems/gitlab-backup-cli/lib/gitlab/backup/cli/shell/pipeline.rb +++ b/gems/gitlab-backup-cli/lib/gitlab/backup/cli/shell/pipeline.rb @@ -8,7 +8,7 @@ class Pipeline # Result data structure from running a pipeline # # @attr [String] stderr - # @attr [Array<Process::Status>] status + # @attr [Array<Process::Status>] status_list # @attr [Float] duration Result = Struct.new(:stderr, :status_list, :duration, keyword_init: true) diff --git a/gems/gitlab-backup-cli/lib/gitlab/backup/cli/utils/tar.rb b/gems/gitlab-backup-cli/lib/gitlab/backup/cli/utils/tar.rb index ac74a3dbc43e38298978b903d341dea1d32c28d1..afaf32357c42d113ae5edb05e75abfe9419a52fc 100644 --- a/gems/gitlab-backup-cli/lib/gitlab/backup/cli/utils/tar.rb +++ b/gems/gitlab-backup-cli/lib/gitlab/backup/cli/utils/tar.rb @@ -44,11 +44,7 @@ def pack_cmd(archive_file:, target_directory:, target:, excludes: []) # Ensure single target or multiple targets are converted to string before adding to args, # to avoid type conversion errors with Pathname - if target.respond_to?(:map) - tar_args += target.map(&:to_s) - else - tar_args << target.to_s - end + tar_args += Array(target).map(&:to_s) Shell::Command.new(cmd, *tar_args) end diff --git a/gems/gitlab-backup-cli/spec/gitlab/backup/cli/shell/pipeline_spec.rb b/gems/gitlab-backup-cli/spec/gitlab/backup/cli/shell/pipeline_spec.rb index ad2837af557c7612690b52940c13051dd6e91469..d150d6b4af04e17955cc1b8796fcebff3717287e 100644 --- a/gems/gitlab-backup-cli/spec/gitlab/backup/cli/shell/pipeline_spec.rb +++ b/gems/gitlab-backup-cli/spec/gitlab/backup/cli/shell/pipeline_spec.rb @@ -12,7 +12,7 @@ it { respond_to :shell_commands } describe '#initialize' do - it 'accept single argument' do + it 'accepts a single argument' do expect { pipeline.new(printf_command) }.not_to raise_exception end diff --git a/spec/lib/backup/targets/files_spec.rb b/spec/lib/backup/targets/files_spec.rb index 9fd09a0e5484ca84bde4f6ec4ed7822365a7a0dd..ad82fd4f224294b0938e4f3f9034017108bb75ad 100644 --- a/spec/lib/backup/targets/files_spec.rb +++ b/spec/lib/backup/targets/files_spec.rb @@ -12,18 +12,17 @@ let(:status_1) { instance_double(Process::Status, success?: false, exitstatus: 1) } let(:pipeline_status_success) { Gitlab::Backup::Cli::Shell::Pipeline::Result.new(status_list: [status_0, status_0]) } let(:pipeline_status_failed) { Gitlab::Backup::Cli::Shell::Pipeline::Result.new(status_list: [status_1, status_1]) } - let(:restore_target) { File.realpath(Dir.mktmpdir('files-target-restore')) } + let(:tmp_backup_restore_dir) { Dir.mktmpdir('files-target-restore') } + let(:restore_target) { File.realpath(tmp_backup_restore_dir) } let(:backup_target) do - tmpdir = Dir.mktmpdir('files-target-backup') - %w[@pages.tmp lost+found @hashed].each do |folder| - path = Pathname(tmpdir).join(folder, 'something', 'else') + path = Pathname(tmp_backup_restore_dir).join(folder, 'something', 'else') FileUtils.mkdir_p(path) FileUtils.touch(path.join('artifacts.zip')) end - File.realpath(tmpdir) + File.realpath(tmp_backup_restore_dir) end before do @@ -36,8 +35,7 @@ end after do - FileUtils.rm_rf(restore_target) - FileUtils.rm_rf(backup_target) + FileUtils.rm_rf([restore_target, backup_target], secure: true) end describe '#restore' do