class LogStash::Outputs::Qingstor::TemporaryFile
Attributes
dir_path[R]
fd[R]
Public Class Methods
create_from_existing_file(file_path, tmp_folder)
click to toggle source
# File lib/logstash/outputs/qingstor/temporary_file.rb, line 57 def self.create_from_existing_file(file_path, tmp_folder) key_parts = Pathname.new(file_path).relative_path_from(tmp_folder) .to_s.split(::File::SEPARATOR) TemporaryFile.new(key_parts.join('/'), ::File.open(file_path, 'r'), tmp_folder.to_s) end
new(key, fd, dir_path)
click to toggle source
# File lib/logstash/outputs/qingstor/temporary_file.rb, line 19 def initialize(key, fd, dir_path) @key = key @fd = fd @dir_path = dir_path @created_at = Time.now end
Public Instance Methods
ctime()
click to toggle source
# File lib/logstash/outputs/qingstor/temporary_file.rb, line 26 def ctime @created_at end
delete!()
click to toggle source
# File lib/logstash/outputs/qingstor/temporary_file.rb, line 44 def delete! begin @fd.close rescue IOError end FileUtils.rm_f(path) end
empty?()
click to toggle source
# File lib/logstash/outputs/qingstor/temporary_file.rb, line 53 def empty? size.zero? end
key()
click to toggle source
# File lib/logstash/outputs/qingstor/temporary_file.rb, line 36 def key @key.gsub(/^\//, '') end
key=(key)
click to toggle source
# File lib/logstash/outputs/qingstor/temporary_file.rb, line 40 def key=(key) @key = key end
size()
click to toggle source
# File lib/logstash/outputs/qingstor/temporary_file.rb, line 30 def size @fd.size rescue IOError ::File.size(path) end