Merge pull request #2281 from reitermarkus/legacy-cache
Move legacy cache and caskroom code to `compat/*`.
This commit is contained in:
commit
ec7530bcda
@ -45,9 +45,6 @@ module Hbc
|
|||||||
|
|
||||||
def self.init
|
def self.init
|
||||||
Cache.ensure_cache_exists
|
Cache.ensure_cache_exists
|
||||||
Cache.delete_legacy_cache
|
|
||||||
|
|
||||||
Caskroom.migrate_caskroom_from_repo_to_prefix
|
|
||||||
Caskroom.ensure_caskroom_exists
|
Caskroom.ensure_caskroom_exists
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -8,12 +8,5 @@ module Hbc
|
|||||||
odebug "Creating Cache at #{Hbc.cache}"
|
odebug "Creating Cache at #{Hbc.cache}"
|
||||||
Hbc.cache.mkpath
|
Hbc.cache.mkpath
|
||||||
end
|
end
|
||||||
|
|
||||||
def delete_legacy_cache
|
|
||||||
return unless Hbc.legacy_cache.exist?
|
|
||||||
|
|
||||||
ohai "Deleting legacy cache at #{Hbc.legacy_cache}..."
|
|
||||||
FileUtils.remove_entry_secure(Hbc.legacy_cache)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -2,21 +2,6 @@ module Hbc
|
|||||||
module Caskroom
|
module Caskroom
|
||||||
module_function
|
module_function
|
||||||
|
|
||||||
def migrate_caskroom_from_repo_to_prefix
|
|
||||||
repo_caskroom = HOMEBREW_REPOSITORY.join("Caskroom")
|
|
||||||
return if Hbc.caskroom.exist?
|
|
||||||
return unless repo_caskroom.directory?
|
|
||||||
|
|
||||||
ohai "Moving Caskroom from HOMEBREW_REPOSITORY to HOMEBREW_PREFIX"
|
|
||||||
|
|
||||||
if Hbc.caskroom.parent.writable?
|
|
||||||
FileUtils.mv repo_caskroom, Hbc.caskroom
|
|
||||||
else
|
|
||||||
opoo "#{Hbc.caskroom.parent} is not writable, sudo is needed to move the Caskroom."
|
|
||||||
SystemCommand.run("/bin/mv", args: [repo_caskroom, Hbc.caskroom.parent], sudo: true)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def ensure_caskroom_exists
|
def ensure_caskroom_exists
|
||||||
return if Hbc.caskroom.exist?
|
return if Hbc.caskroom.exist?
|
||||||
|
|
||||||
|
@ -38,10 +38,6 @@ module Hbc
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def legacy_cache
|
|
||||||
@legacy_cache ||= HOMEBREW_CACHE.join("Casks")
|
|
||||||
end
|
|
||||||
|
|
||||||
attr_writer :cache
|
attr_writer :cache
|
||||||
|
|
||||||
def cache
|
def cache
|
||||||
|
@ -1,2 +1,19 @@
|
|||||||
require "compat/hbc/cask_loader"
|
require "compat/hbc/cask_loader"
|
||||||
require "compat/hbc/cli/update"
|
require "compat/hbc/cli/update"
|
||||||
|
require "compat/hbc/cache"
|
||||||
|
require "compat/hbc/caskroom"
|
||||||
|
|
||||||
|
module Hbc
|
||||||
|
class << self
|
||||||
|
prepend(
|
||||||
|
Module.new do
|
||||||
|
def init
|
||||||
|
Cache.delete_legacy_cache
|
||||||
|
Caskroom.migrate_caskroom_from_repo_to_prefix
|
||||||
|
|
||||||
|
super
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
13
Library/Homebrew/compat/hbc/cache.rb
Normal file
13
Library/Homebrew/compat/hbc/cache.rb
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
module Hbc
|
||||||
|
module Cache
|
||||||
|
module_function
|
||||||
|
|
||||||
|
def delete_legacy_cache
|
||||||
|
legacy_cache = HOMEBREW_CACHE.join("Casks")
|
||||||
|
return unless legacy_cache.exist?
|
||||||
|
|
||||||
|
ohai "Deleting legacy cache at #{legacy_cache}"
|
||||||
|
FileUtils.remove_entry_secure(legacy_cache)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
20
Library/Homebrew/compat/hbc/caskroom.rb
Normal file
20
Library/Homebrew/compat/hbc/caskroom.rb
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
module Hbc
|
||||||
|
module Caskroom
|
||||||
|
module_function
|
||||||
|
|
||||||
|
def migrate_caskroom_from_repo_to_prefix
|
||||||
|
repo_caskroom = HOMEBREW_REPOSITORY.join("Caskroom")
|
||||||
|
return if Hbc.caskroom.exist?
|
||||||
|
return unless repo_caskroom.directory?
|
||||||
|
|
||||||
|
ohai "Moving Caskroom from HOMEBREW_REPOSITORY to HOMEBREW_PREFIX"
|
||||||
|
|
||||||
|
if Hbc.caskroom.parent.writable?
|
||||||
|
FileUtils.mv repo_caskroom, Hbc.caskroom
|
||||||
|
else
|
||||||
|
opoo "#{Hbc.caskroom.parent} is not writable, sudo is needed to move the Caskroom."
|
||||||
|
SystemCommand.run("/bin/mv", args: [repo_caskroom, Hbc.caskroom.parent], sudo: true)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
x
Reference in New Issue
Block a user