Sha256: 2a58b1ff088cb1eadac17fea43847c10d5d9e644049e9a24ba66c10522199d27

Contents?: true

Size: 1.54 KB

Versions: 105

Compression:

Stored size: 1.54 KB

Contents

##   RSence
 #   Copyright 2008 Riassence Inc.
 #   http://riassence.com/
 #
 #   You should have received a copy of the GNU General Public License along
 #   with this software package. If not, contact licensing@riassence.com
 ##


# @private Inner workings of Ticket
module TicketService
# @private Inner workings of Ticket
module Img
  
  # Removes image data and references. Image is removed with
  # its ID which is the same as its URI.
  def del_img( img_id, ses_id=false )
    if ses_id and @imgs[:ses_ids].has_key?( ses_id )
      @imgs[:ses_ids][ses_id].delete( img_id ) if @imgs[:ses_ids][ses_id].include?( img_id )
    end
    @imgs[:by_id].delete( img_id ) if @imgs[:by_id].has_key?( img_id )
  end
  
  # Extends expiration time of disposable files, essentially for keep-alive
  # requests. Image URI is used as an ID and extension is given as seconds.
  def push_keepalive( img_id, keep_alive )
    expiry_time = Time.now.to_i+keep_alive
    @expires[expiry_time] = [] unless @expires.has_key?(expiry_time)
    @expires[expiry_time].push( img_id )
  end
  
  # Removes all expired images.
  def expire_keepalives
    curr_time = Time.now.to_i
    @expires.keys.sort.each do |exp_time|
      if exp_time < curr_time
        @expires[exp_time].size.times do |incr|
          img_id = @expires[exp_time].shift
          if @imgs[:by_id].has_key?(img_id)
            ses_id = @imgs[:by_id][img_id][3]
            del_img( img_id, ses_id )
          end
        end
        @expires.delete(exp_time) if @expires[exp_time].size == 0
      end
    end
  end
  
end
end

Version data entries

105 entries across 105 versions & 2 rubygems

Version Path
rsence-pre-2.2.0.1 plugins/ticket/lib/img.rb
rsence-pre-2.2.0.0 plugins/ticket/lib/img.rb
rsence-2.1.10 plugins/ticket/lib/img.rb
rsence-2.1.9 plugins/ticket/lib/img.rb
rsence-2.1.8 plugins/ticket/lib/img.rb
rsence-pre-2.1.8.1 plugins/ticket/lib/img.rb
rsence-pre-2.1.8.0 plugins/ticket/lib/img.rb
rsence-2.1.7 plugins/ticket/lib/img.rb
rsence-2.1.6 plugins/ticket/lib/img.rb
rsence-2.1.5 plugins/ticket/lib/img.rb
rsence-2.1.4 plugins/ticket/lib/img.rb
rsence-2.1.3 plugins/ticket/lib/img.rb
rsence-2.1.2 plugins/ticket/lib/img.rb
rsence-2.1.1 plugins/ticket/lib/img.rb
rsence-2.1.0 plugins/ticket/lib/img.rb
rsence-pre-2.1.0.21 plugins/ticket/lib/img.rb
rsence-pre-2.1.0.20 plugins/ticket/lib/img.rb
rsence-pre-2.1.0.19 plugins/ticket/lib/img.rb
rsence-pre-2.1.0.18 plugins/ticket/lib/img.rb
rsence-pre-2.1.0.17 plugins/ticket/lib/img.rb