From e078becf4f3b7beaedea35e664a8c3562331ab3e Mon Sep 17 00:00:00 2001 From: commitay Date: Sun, 21 Jan 2018 19:10:30 +1000 Subject: [PATCH] cask move_back: copy / delete --- Library/Homebrew/cask/lib/hbc/artifact/moved.rb | 8 +++++--- Library/Homebrew/test/cask/cli/reinstall_spec.rb | 3 ++- Library/Homebrew/test/cask/cli/uninstall_spec.rb | 3 ++- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/Library/Homebrew/cask/lib/hbc/artifact/moved.rb b/Library/Homebrew/cask/lib/hbc/artifact/moved.rb index 856ab2766f..5a7483543e 100644 --- a/Library/Homebrew/cask/lib/hbc/artifact/moved.rb +++ b/Library/Homebrew/cask/lib/hbc/artifact/moved.rb @@ -62,14 +62,16 @@ module Hbc raise CaskError, "It seems the #{self.class.english_name} source '#{target}' is not there." end - ohai "Moving #{self.class.english_name} '#{target.basename}' back to '#{source}'." + ohai "Copying #{self.class.english_name} '#{target.basename}' back to '#{source}'." source.dirname.mkpath if target.parent.writable? - FileUtils.move(target, source) + FileUtils.cp_r(target, source) else - command.run("/bin/mv", args: [target, source], sudo: true) + command.run("/bin/cp", args: ["-r", target, source], sudo: true) end + + delete(target, force: force, command: command, **options) end def delete(target, force: false, command: nil, **_) diff --git a/Library/Homebrew/test/cask/cli/reinstall_spec.rb b/Library/Homebrew/test/cask/cli/reinstall_spec.rb index 3737a7a701..f56ed986d1 100644 --- a/Library/Homebrew/test/cask/cli/reinstall_spec.rb +++ b/Library/Homebrew/test/cask/cli/reinstall_spec.rb @@ -13,7 +13,8 @@ describe Hbc::CLI::Reinstall, :cask do Already downloaded: .*local-caffeine--1.2.3.zip ==> Verifying checksum for Cask local-caffeine ==> Uninstalling Cask local-caffeine - ==> Moving App 'Caffeine.app' back to '.*Caffeine.app'. + ==> Copying App 'Caffeine.app' back to '.*Caffeine.app'. + ==> Removing App '.*Caffeine.app'. ==> Purging files for version 1.2.3 of Cask local-caffeine ==> Installing Cask local-caffeine ==> Moving App 'Caffeine.app' to '.*Caffeine.app'. diff --git a/Library/Homebrew/test/cask/cli/uninstall_spec.rb b/Library/Homebrew/test/cask/cli/uninstall_spec.rb index 322394de4c..2cac42211a 100644 --- a/Library/Homebrew/test/cask/cli/uninstall_spec.rb +++ b/Library/Homebrew/test/cask/cli/uninstall_spec.rb @@ -12,7 +12,8 @@ describe Hbc::CLI::Uninstall, :cask do output = Regexp.new <<~EOS ==> Uninstalling Cask local-caffeine - ==> Moving App 'Caffeine.app' back to '.*Caffeine.app'. + ==> Copying App 'Caffeine.app' back to '.*Caffeine.app'. + ==> Removing App '.*Caffeine.app'. ==> Purging files for version 1.2.3 of Cask local-caffeine EOS