Sha256: 396927ef2088703189433d28d0be31d4e3226fb9b760f3e828362261f184494c

Contents?: true

Size: 1 KB

Versions: 5

Compression:

Stored size: 1 KB

Contents

require 'puppet/checksum'
require 'puppet/indirector/file'

class Puppet::Checksum::File < Puppet::Indirector::File
    desc "Store files in a directory set based on their checksums."

    def initialize
        Puppet.settings.use(:filebucket)
    end

    def path(checksum)
        path = []
        path << Puppet[:bucketdir]                              # Start with the base directory
        path << checksum[0..7].split("").join(File::SEPARATOR)  # Add sets of directories based on the checksum
        path << checksum                                        # And the full checksum name itself
        path << "contents"                                      # And the actual file name

        path.join(File::SEPARATOR)
    end

    def save(file)
        path = File.dirname(path(file.name))

        # Make the directories if necessary.
        unless FileTest.directory?(path)
            Puppet::Util.withumask(0007) do
                FileUtils.mkdir_p(path)
            end
        end

        super
    end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
puppet-0.24.0 lib/puppet/indirector/checksum/file.rb
puppet-0.24.4 lib/puppet/indirector/checksum/file.rb
puppet-0.24.1 lib/puppet/indirector/checksum/file.rb
puppet-0.24.2 lib/puppet/indirector/checksum/file.rb
puppet-0.24.3 lib/puppet/indirector/checksum/file.rb