cleanup: some speedup optimisations.
- avoid calling `rm_ds_store` multiple times when unnecessary - use native Ruby method to remove `.DS_Store` files as it saves shelling out to `find` and is a bit quicker.
This commit is contained in:
parent
1e725f486e
commit
ea0e7f6d62
@ -165,7 +165,7 @@ module Homebrew
|
|||||||
def clean!(quiet: false, periodic: false)
|
def clean!(quiet: false, periodic: false)
|
||||||
if args.empty?
|
if args.empty?
|
||||||
Formula.installed.sort_by(&:name).each do |formula|
|
Formula.installed.sort_by(&:name).each do |formula|
|
||||||
cleanup_formula(formula, quiet: quiet)
|
cleanup_formula(formula, quiet: quiet, ds_store: false)
|
||||||
end
|
end
|
||||||
cleanup_cache
|
cleanup_cache
|
||||||
cleanup_logs
|
cleanup_logs
|
||||||
@ -210,17 +210,17 @@ module Homebrew
|
|||||||
@unremovable_kegs ||= []
|
@unremovable_kegs ||= []
|
||||||
end
|
end
|
||||||
|
|
||||||
def cleanup_formula(formula, quiet: false)
|
def cleanup_formula(formula, quiet: false, ds_store: true)
|
||||||
formula.eligible_kegs_for_cleanup(quiet: quiet)
|
formula.eligible_kegs_for_cleanup(quiet: quiet)
|
||||||
.each(&method(:cleanup_keg))
|
.each(&method(:cleanup_keg))
|
||||||
cleanup_cache(Pathname.glob(cache/"#{formula.name}--*"))
|
cleanup_cache(Pathname.glob(cache/"#{formula.name}--*"))
|
||||||
rm_ds_store([formula.rack])
|
rm_ds_store([formula.rack]) if ds_store
|
||||||
cleanup_lockfiles(FormulaLock.new(formula.name).path)
|
cleanup_lockfiles(FormulaLock.new(formula.name).path)
|
||||||
end
|
end
|
||||||
|
|
||||||
def cleanup_cask(cask)
|
def cleanup_cask(cask, ds_store: true)
|
||||||
cleanup_cache(Pathname.glob(cache/"Cask/#{cask.token}--*"))
|
cleanup_cache(Pathname.glob(cache/"Cask/#{cask.token}--*"))
|
||||||
rm_ds_store([cask.caskroom_path])
|
rm_ds_store([cask.caskroom_path]) if ds_store
|
||||||
cleanup_lockfiles(CaskLock.new(cask.token).path)
|
cleanup_lockfiles(CaskLock.new(cask.token).path)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -383,11 +383,9 @@ module Homebrew
|
|||||||
HOMEBREW_PREFIX/"Caskroom",
|
HOMEBREW_PREFIX/"Caskroom",
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
dirs.select(&:directory?).each do |dir|
|
dirs.select(&:directory?)
|
||||||
system_command "find",
|
.flat_map { |d| Pathname.glob("#{d}/**/.DS_Store") }
|
||||||
args: [dir, "-name", ".DS_Store", "-delete"],
|
.each(&:unlink)
|
||||||
print_stderr: false
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def prune_prefix_symlinks_and_directories
|
def prune_prefix_symlinks_and_directories
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user