Created
April 19, 2012 05:14
-
-
Save hSATAC/2418763 to your computer and use it in GitHub Desktop.
delete Redmine duplicated attachments
This file contains hidden or 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
| def del_dup | |
| for a in Attachment.all | |
| dup = Attachment.find(:all, :conditions=>{:filename => a.filename, :filesize=>a.filesize}) | |
| if dup.count > 1 | |
| puts "Duplicated Attachment found! Start purging..." | |
| puts "item # #{a.id} #{a.filename} (#{a.filesize}) got #{dup.count} duplicated items." | |
| for as in dup[1..-1] | |
| puts "Deleting #{as.id}..." | |
| as.delete_from_disk | |
| as.destroy | |
| end | |
| break | |
| end | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment