Boinc applications are sometimes updated and old ones still remain in data directory.
Although the server might discard new ones later, usually old ones are just waste of the storage.
This Ruby script will garbage-collect the data directory.
boinc_gc.rb
#!/usr/bin/env ruby
#BOINC Garbage Collector (remove old files)
if ARGV.empty? or ARGV[0]!='--yes'
dry=true
puts 'Usage: boinc_gc.rb [--yes]'
puts 'without --yes, it runs in dry-run mode.'
else
dry=false
end
#http://wcg.wikia.com/wiki/Data_directory
DIR={
win: 'C:/Documents and Settings/All Users/Application Data/BOINC/projects',
#win: 'C:/ProgramData/BOINC/projects',
osx: '/Library/Application Support/BOINC Data/projects',
linux: '/var/lib/boinc-client/projects',
freebsd: '/var/db/boinc/projects',
}
if RUBY_PLATFORM.include?('win32') || RUBY_PLATFORM.include?('mingw32')
dir=DIR[:win]
elsif RUBY_PLATFORM.include?('linux')
dir=DIR[:linux]
elsif RUBY_PLATFORM.include?('darwin')
dir=DIR[:osx]
elsif RUBY_PLATFORM.include?('freebsd')
dir=DIR[:freebsd]
else
raise 'Unknown platform '+RUBY_PLATFORM
end
FILESIZE_THRESHOLD=1000000 #1MB
require 'find'
dict=Hash.new{|h,k|h[k]=[]}
Find.find(dir){|path|
size=File.size(path)
if size>=10**7
base=path #File.basename(path)
#x86_64 can exec x86 apps, so there might be mixture.
base=base.gsub('i386','').gsub('i586','').gsub('i686','').gsub('x86_64','')
if base=~/_([\d\.]+)_/
base.sub!(/_([\d\.]+)_/,'')
dict[base].push({ver:$1,size:size,name:path})
end
end
}
totalsize=0
dict.each_value{|v|
a=v.sort_by{|e|e[:ver].split('.').map(&:to_i)}
(a.size-1).times{|i|
totalsize+=a[i][:size]
puts 'Removing '+a[i][:name]
File.unlink(a[i][:name]) unless dry
}
}
puts 'Saved '+totalsize.to_s+' bytes.'
検索用:BOINCをガベージコレクションする(古いバージョンのアプリケーションを削除する)