Class: Nearline::Models::ArchivedFile::FileInformation
- Inherits:
-
Object
- Object
- Nearline::Models::ArchivedFile::FileInformation
- Defined in:
- lib/nearline/archived_file.rb
Instance Attribute Summary collapse
-
#archived_file_parameters ⇒ Object
readonly
Returns the value of attribute archived_file_parameters.
-
#is_directory ⇒ Object
readonly
Returns the value of attribute is_directory.
-
#path_hash ⇒ Object
readonly
Returns the value of attribute path_hash.
-
#stat ⇒ Object
readonly
Returns the value of attribute stat.
Instance Method Summary collapse
- #build_parameters ⇒ Object
- #file_content_entry_for_files_only ⇒ Object
- #generate_path_hash ⇒ Object
-
#initialize(file_path, manifest) ⇒ FileInformation
constructor
A new instance of FileInformation.
- #read_stat ⇒ Object
Constructor Details
#initialize(file_path, manifest) ⇒ FileInformation
Returns a new instance of FileInformation.
45 46 47 48 49 50 51 52 |
# File 'lib/nearline/archived_file.rb', line 45 def initialize(file_path, manifest) @manifest = manifest @file_path = file_path @stat = read_stat @is_directory = File.directory?(file_path) @path_hash = generate_path_hash @archived_file_parameters = build_parameters end |
Instance Attribute Details
#archived_file_parameters ⇒ Object (readonly)
Returns the value of attribute archived_file_parameters.
44 45 46 |
# File 'lib/nearline/archived_file.rb', line 44 def archived_file_parameters @archived_file_parameters end |
#is_directory ⇒ Object (readonly)
Returns the value of attribute is_directory.
44 45 46 |
# File 'lib/nearline/archived_file.rb', line 44 def is_directory @is_directory end |
#path_hash ⇒ Object (readonly)
Returns the value of attribute path_hash.
44 45 46 |
# File 'lib/nearline/archived_file.rb', line 44 def path_hash @path_hash end |
#stat ⇒ Object (readonly)
Returns the value of attribute stat.
44 45 46 |
# File 'lib/nearline/archived_file.rb', line 44 def stat @stat end |
Instance Method Details
#build_parameters ⇒ Object
80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/nearline/archived_file.rb', line 80 def build_parameters return nil if @stat.nil? { :system_name => @manifest.system_name, :path => @file_path, :path_hash => @path_hash, :file_content => file_content_entry_for_files_only, :uid => @stat.uid, :gid => @stat.gid, :mtime => @stat.mtime.to_i, :mode => @stat.mode, :is_directory => @is_directory } end |
#file_content_entry_for_files_only ⇒ Object
75 76 77 78 |
# File 'lib/nearline/archived_file.rb', line 75 def file_content_entry_for_files_only return FileContent.fresh_entry unless @is_directory return nil end |
#generate_path_hash ⇒ Object
64 65 66 67 68 69 70 71 72 73 |
# File 'lib/nearline/archived_file.rb', line 64 def generate_path_hash return nil if @stat.nil? target = [@manifest.system_name, @file_path, @stat.uid, @stat.gid, @stat.mtime.to_i, @stat.mode].join(':') Digest::SHA1.hexdigest(target) end |
#read_stat ⇒ Object
54 55 56 57 58 59 60 61 62 |
# File 'lib/nearline/archived_file.rb', line 54 def read_stat stat = nil begin stat = File.stat(@file_path) rescue @manifest.add_log("File not found on stat: #{@file_path}") end stat end |