Remove .DS_Store per-cask/formula.
This commit is contained in:
parent
8e703e30ba
commit
678ce2d7bd
@ -5,6 +5,30 @@ require "hbc/cask_loader"
|
|||||||
module CleanupRefinement
|
module CleanupRefinement
|
||||||
LATEST_CASK_DAYS = 7
|
LATEST_CASK_DAYS = 7
|
||||||
|
|
||||||
|
refine Enumerator do
|
||||||
|
def parallel
|
||||||
|
queue = Queue.new
|
||||||
|
|
||||||
|
each do |element|
|
||||||
|
queue.enq(element)
|
||||||
|
end
|
||||||
|
|
||||||
|
workers = (0...Hardware::CPU.cores).map do
|
||||||
|
Thread.new do
|
||||||
|
Kernel.loop do
|
||||||
|
begin
|
||||||
|
yield queue.deq(true)
|
||||||
|
rescue ThreadError
|
||||||
|
break # if queue is empty
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
workers.each(&:join)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
refine Pathname do
|
refine Pathname do
|
||||||
def incomplete?
|
def incomplete?
|
||||||
extname.end_with?(".incomplete")
|
extname.end_with?(".incomplete")
|
||||||
@ -149,10 +173,12 @@ module Homebrew
|
|||||||
def cleanup_formula(formula)
|
def cleanup_formula(formula)
|
||||||
formula.eligible_kegs_for_cleanup.each(&method(:cleanup_keg))
|
formula.eligible_kegs_for_cleanup.each(&method(:cleanup_keg))
|
||||||
cleanup_cache(Pathname.glob(cache/"#{formula.name}--*"))
|
cleanup_cache(Pathname.glob(cache/"#{formula.name}--*"))
|
||||||
|
rm_ds_store([formula.rack])
|
||||||
end
|
end
|
||||||
|
|
||||||
def cleanup_cask(cask)
|
def cleanup_cask(cask)
|
||||||
cleanup_cache(Pathname.glob(cache/"Cask/#{cask.token}--*"))
|
cleanup_cache(Pathname.glob(cache/"Cask/#{cask.token}--*"))
|
||||||
|
rm_ds_store([cask.caskroom_path])
|
||||||
end
|
end
|
||||||
|
|
||||||
def cleanup_keg(keg)
|
def cleanup_keg(keg)
|
||||||
@ -214,22 +240,13 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def rm_ds_store
|
def rm_ds_store(dirs = nil)
|
||||||
paths = Queue.new
|
dirs ||= %w[Caskroom Cellar Frameworks Library bin etc include lib opt sbin share var]
|
||||||
%w[Cellar Frameworks Library bin etc include lib opt sbin share var]
|
.map { |path| HOMEBREW_PREFIX/path }
|
||||||
.map { |p| HOMEBREW_PREFIX/p }.each { |p| paths << p if p.exist? }
|
|
||||||
workers = (0...Hardware::CPU.cores).map do
|
dirs.select(&:directory?).each.parallel do |dir|
|
||||||
Thread.new do
|
system_command "find", args: [dir, "-name", ".DS_Store", "-delete"], print_stderr: false
|
||||||
Kernel.loop do
|
|
||||||
begin
|
|
||||||
quiet_system "find", paths.deq(true), "-name", ".DS_Store", "-delete"
|
|
||||||
rescue ThreadError
|
|
||||||
break # if queue is empty
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
workers.map(&:join)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user