HomePhorge

(#9983) Checksum files in binary mode
489a679cd4beUnpublished

Unpublished Commit ยท Learn More

Repository Importing: This repository is still importing.

Description

(#9983) Checksum files in binary mode

Previously, we were opening files in text mode when calculating file
checksums. On Windows, '\r\n' characters are automatically translated
to '\n', which corrupts the resulting checksum.

This commit ensures we open files in binary mode, similar to what
Digest::MD5.file(path).hexdigest does. Binary mode is a noop on Unix.

Similarly, Puppet::Type::File#write was writing the file content in
text mode, which was later validated using the checksum code, now
reading in binary mode. So Puppet::Type::File was changed to use
binary mode as well.

Also, some of the tests were writing files in text mode, but
checksumming them in binary mode, and obviously failing. Changed the
spec tests to write in binary mode also.

Details

Provenance
Josh Cooper <josh@puppetlabs.com>Authored on
vanmeeuwenPushed on Jun 2 2015, 2:22 PM
Parents
rPUf7bfa05d1dfa: (#9983) Add method for reading binary files
Branches
Unknown
Tags
Unknown

Event Timeline

Josh Cooper <josh@puppetlabs.com> committed rPU489a679cd4be: (#9983) Checksum files in binary mode (authored by Josh Cooper <josh@puppetlabs.com>).Nov 1 2011, 5:27 PM