@@ -175,7 +175,7 class Attachment < ActiveRecord::Base | |||||
175 | def self.find_by_token(token) |
|
175 | def self.find_by_token(token) | |
176 | if token.to_s =~ /^(\d+)\.([0-9a-f]+)$/ |
|
176 | if token.to_s =~ /^(\d+)\.([0-9a-f]+)$/ | |
177 | attachment_id, attachment_digest = $1, $2 |
|
177 | attachment_id, attachment_digest = $1, $2 | |
178 |
attachment = Attachment. |
|
178 | attachment = Attachment.where(:id => attachment_id, :digest => attachment_digest).first | |
179 | if attachment && attachment.container.nil? |
|
179 | if attachment && attachment.container.nil? | |
180 | attachment |
|
180 | attachment | |
181 | end |
|
181 | end | |
@@ -200,8 +200,7 class Attachment < ActiveRecord::Base | |||||
200 | end |
|
200 | end | |
201 |
|
201 | |||
202 | def self.prune(age=1.day) |
|
202 | def self.prune(age=1.day) | |
203 |
|
|
203 | Attachment.where("created_on < ? AND (container_type IS NULL OR container_type = '')", Time.now - age).destroy_all | |
204 | attachments.each(&:destroy) |
|
|||
205 | end |
|
204 | end | |
206 |
|
205 | |||
207 | private |
|
206 | private |
General Comments 0
You need to be logged in to leave comments.
Login now