Method: Puppet::FileServing::Metadata#collect

Defined in:
lib/puppet/file_serving/metadata.rb

#collect(source_permissions = nil) ⇒ Object

Retrieve the attributes for this file, relative to a base directory. Note that Puppet::FileSystem.stat(path) raises Errno::ENOENT if the file is absent and this method does not catch that exception.



101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
# File 'lib/puppet/file_serving/metadata.rb', line 101

def collect(source_permissions = nil)
  real_path = full_path

  stat = collect_stat(real_path)
  @owner = stat.owner
  @group = stat.group
  @ftype = stat.ftype

  # We have to mask the mode, yay.
  @mode = stat.mode & 007777

  case stat.ftype
  when "file"
    @checksum = ("{#{@checksum_type}}") + send("#{@checksum_type}_file", real_path).to_s
  when "directory" # Always just timestamp the directory.
    @checksum_type = "ctime"
    @checksum = ("{#{@checksum_type}}") + send("#{@checksum_type}_file", path).to_s
  when "link"
    @destination = Puppet::FileSystem.readlink(real_path)
    @checksum = ("{#{@checksum_type}}") + send("#{@checksum_type}_file", real_path).to_s rescue nil
  else
    raise ArgumentError, _("Cannot manage files of type %{file_type}") % { file_type: stat.ftype }
  end
end