Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cleanup: some speedup optimisations. #6468

Merged
merged 1 commit into from Sep 19, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 8 additions & 10 deletions Library/Homebrew/cleanup.rb
Expand Up @@ -165,7 +165,7 @@ def periodic_clean!
def clean!(quiet: false, periodic: false)
if args.empty?
Formula.installed.sort_by(&:name).each do |formula|
cleanup_formula(formula, quiet: quiet)
cleanup_formula(formula, quiet: quiet, ds_store: false)
end
cleanup_cache
cleanup_logs
Expand Down Expand Up @@ -210,17 +210,17 @@ def unremovable_kegs
@unremovable_kegs ||= []
end

def cleanup_formula(formula, quiet: false)
def cleanup_formula(formula, quiet: false, ds_store: true)
formula.eligible_kegs_for_cleanup(quiet: quiet)
.each(&method(:cleanup_keg))
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)
end

def cleanup_cask(cask)
def cleanup_cask(cask, ds_store: true)
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)
end

Expand Down Expand Up @@ -383,11 +383,9 @@ def rm_ds_store(dirs = nil)
HOMEBREW_PREFIX/"Caskroom",
]
end
dirs.select(&:directory?).each do |dir|
system_command "find",
args: [dir, "-name", ".DS_Store", "-delete"],
print_stderr: false
end
dirs.select(&:directory?)
.flat_map { |d| Pathname.glob("#{d}/**/.DS_Store") }
.each(&:unlink)
end

def prune_prefix_symlinks_and_directories
Expand Down