Class: ContentServer::Stream

Inherits:
Object
  • Object
show all
Defined in:
lib/content_server/file_streamer.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(checksum, path, file, size) ⇒ Stream

Returns a new instance of Stream.



18
19
20
21
22
23
# File 'lib/content_server/file_streamer.rb', line 18

def initialize(checksum, path, file, size)
  @checksum = checksum
  @path = path
  @file = file
  @size = size
end

Instance Attribute Details

#checksumObject (readonly)

Returns the value of attribute checksum.



17
18
19
# File 'lib/content_server/file_streamer.rb', line 17

def checksum
  @checksum
end

#fileObject (readonly)

Returns the value of attribute file.



17
18
19
# File 'lib/content_server/file_streamer.rb', line 17

def file
  @file
end

#pathObject (readonly)

Returns the value of attribute path.



17
18
19
# File 'lib/content_server/file_streamer.rb', line 17

def path
  @path
end

#sizeObject (readonly)

Returns the value of attribute size.



17
18
19
# File 'lib/content_server/file_streamer.rb', line 17

def size
  @size
end

#tmp_pathObject (readonly)

Returns the value of attribute tmp_path.



17
18
19
# File 'lib/content_server/file_streamer.rb', line 17

def tmp_path
  @tmp_path
end

Class Method Details

.close_delete_stream(checksum, streams_hash) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/content_server/file_streamer.rb', line 25

def self.close_delete_stream(checksum, streams_hash)
  if streams_hash.key?(checksum)
    Log.debug1("close_delete_stream %s", streams_hash[checksum].path)
    begin
      streams_hash[checksum].file.close()
    rescue IOError => e
      Log.warning("While closing stream, could not close file #{streams_hash[checksum].path}." \
                    " IOError msg:#{e.to_s}")
    end
    streams_hash.delete(checksum)
    $process_vars.set('Streams size', streams_hash.size)
  end
end