Sha256: 265938082df63918601187051138181c12e1a2391208383e24e6c0140e0f4001

Contents?: true

Size: 1.16 KB

Versions: 37

Compression:

Stored size: 1.16 KB

Contents

# -*- encoding : utf-8 -*-
class Card; module Set; class All; module FileUtils; extend Card::Set
# ~~ above autogenerated; below pulled from /Users/ethan/dev/wagn/gem/card/mod/carrierwave/set/all/file_utils.rb ~~
module ClassMethods
  def update_all_storage_locations
    Card.search(type_id: ["in", FileID, ImageID])
        .each(&:update_storage_location!)
  end

  def delete_tmp_files_of_cached_uploads
    draft_actions_with_attachment.each do |action|
      # we don't want to delete uploads in progress
      next unless old_enough?(action.created_at) && (card = action.card)
      card.delete_files_for_action action
      action.delete
    end
  end

  def old_enough? time, expiration_time=5.day.to_i
    Time.now - time > expiration_time
  end

  def draft_actions_with_attachment
    Card::Action.find_by_sql(
      "SELECT * FROM card_actions "\
        "INNER JOIN cards ON card_actions.card_id = cards.id "\
        "WHERE cards.type_id IN (#{Card::FileID}, #{Card::ImageID}) "\
        "AND card_actions.draft = true"
    )
  end
end


# ~~ below autogenerated; above pulled from /Users/ethan/dev/wagn/gem/card/mod/carrierwave/set/all/file_utils.rb ~~
end;end;end;end;

Version data entries

37 entries across 37 versions & 1 rubygems

Version Path
card-1.99.6 tmpsets/set/mod015-carrierwave/all/file_utils.rb
card-1.99.5 tmpsets/set/mod015-carrierwave/all/file_utils.rb
card-1.97.0.1 tmpsets/set/mod015-carrierwave/all/file_utils.rb
card-1.97.0 tmpsets/set/mod015-carrierwave/all/file_utils.rb
card-1.96.8 tmpsets/set/mod015-carrierwave/all/file_utils.rb
card-1.96.7 tmpsets/set/mod015-carrierwave/all/file_utils.rb
card-1.96.6 tmpsets/set/mod015-carrierwave/all/file_utils.rb
card-1.96.5 tmpsets/set/mod015-carrierwave/all/file_utils.rb
card-1.96.4 tmpsets/set/mod015-carrierwave/all/file_utils.rb
card-1.96.3 tmpsets/set/mod015-carrierwave/all/file_utils.rb
card-1.96.2 tmpsets/set/mod015-carrierwave/all/file_utils.rb
card-1.96.1 tmpsets/set/mod015-carrierwave/all/file_utils.rb
card-1.96.0 tmpsets/set/mod015-carrierwave/all/file_utils.rb
card-1.95.3 tmpsets/set/mod015-carrierwave/all/file_utils.rb
card-1.95.2 tmpsets/set/mod015-carrierwave/all/file_utils.rb
card-1.95.1 tmpsets/set/mod015-carrierwave/all/file_utils.rb
card-1.95.0 tmpsets/set/mod015-carrierwave/all/file_utils.rb
card-1.94.1 tmpsets/set/mod015-carrierwave/all/file_utils.rb
card-1.94.0 tmpsets/set/mod015-carrierwave/all/file_utils.rb
card-1.93.13 tmpsets/set/mod015-carrierwave/all/file_utils.rb