HomePhorge

(#6541) Fix content with checksum truncation bug
7c2a98021205Unpublished

Unpublished Commit ยท Learn More

Repository Importing: This repository is still importing.

Description

(#6541) Fix content with checksum truncation bug

The patch for #6107 fd73874147a1aaa3a047f904a0bc1ae67780a2e4 introduced
a bug when content was an invalid checksum. Rather than error the
checksum was invalid, it would overwrite the file with empty string,
essentially truncating it.

The problem with #6107 is that when I wrote it, I didn't realize that
the content parameter was munged to be nil when it was a checksum, and
then chunking method special cased nil content to mean you should check
the filebucket. #6107 intended to fix the case where content REALLY WAS
nil, and handle that by returning an empty string.

This patch fixes it so that we check to see if we really passed in a
checksum when chunking, and only then going to the filebucket.

Surprisingly it is possible to have a content checksum should value set
from source, so we have to be careful not to assume the use of the
filebucket whenever there's a checksum. The following manifest produces
this situation:

file { "/tmp/mydir" :
  source  => '/tmp/sourcedir',
  recurse => true,
}

I've said it before, and sure I'll say it again, but long term the file
provider really needs a refactor. I'll write some acceptance tests for
file behavior right after committing this so that the refactoring will
be easier.

Reviewed-by: Daniel Pittman <daniel@puppetlabs.com>

Details

Provenance
Matt Robinson <matt@puppetlabs.com>Authored on
Jacob Helwig <jacob@puppetlabs.com>Committed on Mar 3 2011, 1:06 AM
vanmeeuwenPushed on Jun 2 2015, 2:22 PM
Parents
rPU63e911f90c0a: (#6418) Recursive files shouldn't be audited
Branches
Unknown
Tags
Unknown

Event Timeline

Jacob Helwig <jacob@puppetlabs.com> committed rPU7c2a98021205: (#6541) Fix content with checksum truncation bug (authored by Matt Robinson <matt@puppetlabs.com>).Mar 3 2011, 1:06 AM