file.rb

Path: lib/puppet/type/file.rb
Last Update: Fri Aug 03 10:17:44 +0000 2012

Required files

digest/md5   cgi   etc   uri   fileutils   puppet/network/handler   puppet/util/diff   puppet/util/checksums   puppet/network/client   puppet/util/backups   puppet/type/file/checksum   puppet/type/file/content   puppet/type/file/source   puppet/type/file/target   puppet/type/file/ensure   puppet/type/file/owner   puppet/type/file/group   puppet/type/file/mode   puppet/type/file/type   puppet/type/file/selcontext   puppet/type/file/ctime   puppet/type/file/mtime  

Methods

Included Modules

Puppet::Util::MethodHelper Puppet::Util::Checksums Puppet::Util::Backups

Constants

CREATORS = [:content, :source, :target]
SOURCE_ONLY_CHECKSUMS = [:none, :ctime, :mtime]

Public Class methods

Public Instance methods

Determine the user to write files as.

Create any children via recursion or whatever.

Does the file currently exist? Just checks for whether we have a stat

Make sure the file we wrote out is what we think it is.

We have to do some extra finishing, to retrieve our bucket if there is one.

Configure discovered resources to be purged.

Create a new file or directory object as a child to the current object.

Files handle paths specially, because they just lengthen their path names, rather than including the full parent‘s title each time.

There are some cases where all of the work does not get done on file creation/modification, so we have to do some extra checking.

Should we be purging?

Recursively generate a list of file resources, which will be used to copy remote files, manage local files, and/or make links to map to another directory.

A simple method for determining whether we should be recursing.

Recurse the target of the link.

Recurse the file itself, returning a Metadata instance for every found file.

Recurse against our remote file.

Remove any existing data. This is only used when dealing with links or directories.

This is to fix bug 2296, where two files recurse over the same set of files. It‘s a rare case, and when it does happen you‘re not likely to have many actual conflicts, which is good, because this is a pretty inefficient implementation.

Set the checksum, from another property. There are multiple properties that modify the contents of a file, and they need the ability to make sure that the checksum value is in sync.

Should this thing be a normal file? This is a relatively complex way of determining whether we‘re trying to create a normal file, and it‘s here so that the logic isn‘t visible in the content property.

We have to hack this just a little bit, because otherwise we‘ll get an error when the target and the contents are created as properties on the far side.

Should we validate the checksum of the file we‘re writing?

Write out the file. Requires the property name for logging. Write will be done by the content property, along with checksum computation

write the current content. Note that if there is no content property simply opening the file with ‘w’ as done in write is enough to truncate or write an empty length file.

[Validate]