Class: BBFS::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.



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

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.



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

def checksum
  @checksum
end

#fileObject (readonly)

Returns the value of attribute file.



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

def file
  @file
end

#pathObject (readonly)

Returns the value of attribute path.



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

def path
  @path
end

#sizeObject (readonly)

Returns the value of attribute size.



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

def size
  @size
end

#tmp_pathObject (readonly)

Returns the value of attribute tmp_path.



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

def tmp_path
  @tmp_path
end

Class Method Details

.close_delete_stream(checksum, streams_hash) ⇒ Object



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

def self.close_delete_stream(checksum, streams_hash)
  if streams_hash.key?(checksum)
    Log.info("close_delete_stream #{streams_hash[checksum].file}")
    begin
      streams_hash[checksum].file.close()
    rescue IOError => e
      Log.warning("While closing stream, could not close file #{streams_hash[checksum].path}." \
                  " #{e.to_s}")
    end
    streams_hash.delete(checksum)
  end
end