@ -349,11 +349,16 @@ class Attachment < ActiveRecord::Base
# Deletes the file from the file system if it's not referenced by other attachments
defdelete_from_disk
ifAttachment.where("disk_filename = ? AND id <> ?",disk_filename,id).empty?
#资源存在,且历史记录为0 且 该资源没有存在任何拷贝才能删除资源
ifAttachment.where("disk_filename = ? AND id <> ?",disk_filename,id).empty?&&self.attachment_histories.count==0&&Attachment.where('copy_from = ?',self.id).count==0
delete_from_disk!
end
end
defdestroyable
Attachment.where("disk_filename = ? AND id <> ?",disk_filename,id).empty?&&self.attachment_histories.count==0&&Attachment.where('copy_from = ?',self.id).count==0