diff options
| author | Markus Reiter | 2016-09-20 15:11:33 +0200 |
|---|---|---|
| committer | Markus Reiter | 2016-09-23 15:30:05 +0200 |
| commit | 59212445da7048233ef32705433e548783fcf84b (patch) | |
| tree | d1ff519490652760f5c37aa55032d82482ebbda1 /Library/Homebrew/cask/lib/hbc/cache.rb | |
| parent | b957a1b7e6c1305617cff429f16f73f0c8ec604c (diff) | |
| download | brew-59212445da7048233ef32705433e548783fcf84b.tar.bz2 | |
Run `rubocop —auto-correct`.
Diffstat (limited to 'Library/Homebrew/cask/lib/hbc/cache.rb')
| -rw-r--r-- | Library/Homebrew/cask/lib/hbc/cache.rb | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/Library/Homebrew/cask/lib/hbc/cache.rb b/Library/Homebrew/cask/lib/hbc/cache.rb index 9fc5fe0f3..7ae5fcc8c 100644 --- a/Library/Homebrew/cask/lib/hbc/cache.rb +++ b/Library/Homebrew/cask/lib/hbc/cache.rb @@ -3,32 +3,32 @@ module Hbc::Cache def ensure_cache_exists return if Hbc.cache.exist? + odebug "Creating Cache at #{Hbc.cache}" Hbc.cache.mkpath end def migrate_legacy_cache - if Hbc.legacy_cache.exist? - ohai "Migrating cached files to #{Hbc.cache}..." - - Hbc.legacy_cache.children.select(&:symlink?).each do |symlink| - file = symlink.readlink + return unless Hbc.legacy_cache.exist? - new_name = file.basename - .sub(%r{\-((?:(\d|#{Hbc::DSL::Version::DIVIDER_REGEX})*\-\2*)*[^\-]+)$}x, - '--\1') + ohai "Migrating cached files to #{Hbc.cache}..." + Hbc.legacy_cache.children.select(&:symlink?).each do |symlink| + file = symlink.readlink - renamed_file = Hbc.cache.join(new_name) + new_name = file.basename + .sub(%r{\-((?:(\d|#{Hbc::DSL::Version::DIVIDER_REGEX})*\-\2*)*[^\-]+)$}x, + '--\1') - if file.exist? - puts "#{file} -> #{renamed_file}" - FileUtils.mv(file, renamed_file) - end + renamed_file = Hbc.cache.join(new_name) - FileUtils.rm(symlink) + if file.exist? + puts "#{file} -> #{renamed_file}" + FileUtils.mv(file, renamed_file) end - FileUtils.remove_entry_secure(Hbc.legacy_cache) + FileUtils.rm(symlink) end + + FileUtils.remove_entry_secure(Hbc.legacy_cache) end end |
