Skip to content

Commit

Permalink
Code cleanup.
Browse files Browse the repository at this point in the history
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@9716 e93f8b46-1217-0410-a6f0-8f06a7374b81
  • Loading branch information
jplang committed May 25, 2012
1 parent aa18cd5 commit d664fdc
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions app/models/attachment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ def token
def self.find_by_token(token)
if token.to_s =~ /^(\d+)\.([0-9a-f]+)$/
attachment_id, attachment_digest = $1, $2
attachment = Attachment.first(:conditions => {:id => attachment_id, :digest => attachment_digest})
attachment = Attachment.where(:id => attachment_id, :digest => attachment_digest).first
if attachment && attachment.container.nil?
attachment
end
Expand All @@ -200,8 +200,7 @@ def self.latest_attach(attachments, filename)
end

def self.prune(age=1.day)
attachments = Attachment.all(:conditions => ["created_on < ? AND (container_type IS NULL OR container_type = '')", Time.now - age])
attachments.each(&:destroy)
Attachment.where("created_on < ? AND (container_type IS NULL OR container_type = '')", Time.now - age).destroy_all
end

private
Expand Down

0 comments on commit d664fdc

Please sign in to comment.