Created
August 7, 2010 23:15
-
-
Save insane-dreamer/513307 to your computer and use it in GitHub Desktop.
rake to delete attachments created with tests
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace :paperclip do | |
desc 'deletes stale attachments (i.e., created by tests)' | |
task :stale => :environment do | |
Dir.chdir('public/system/items') | |
dirs = Dir.glob("[^\.]*") | |
items = Asset.all.collect(&:id) | |
count = 0 | |
dirs.each { |d| | |
unless items.include?(d.to_i) | |
print '.' | |
system("rm -rf #{d}") | |
count += 1 | |
end | |
} | |
puts "#{count} folders deleted (for which no item found in database)." | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment