diff options
author | Luke Kanies <luke@madstop.com> | 2007-10-17 11:44:03 -0500 |
---|---|---|
committer | Luke Kanies <luke@madstop.com> | 2007-10-17 11:44:03 -0500 |
commit | d0bd48cc50cf90440429569e748877ab6e23491f (patch) | |
tree | f7dadaa96bb2fce07bf9efaef2b610d890c59b89 /lib/puppet/util | |
parent | a815f7888b021a46332c23450795f057533d0093 (diff) | |
download | puppet-d0bd48cc50cf90440429569e748877ab6e23491f.tar.gz puppet-d0bd48cc50cf90440429569e748877ab6e23491f.tar.xz puppet-d0bd48cc50cf90440429569e748877ab6e23491f.zip |
Adding the first pass at modifying file serving
to work with indirection. I've split the
fileserver handler into four pieces: Mount (which so
far I've just copied wholesale), Configuration (responsible
for reading the configuration file and determining what's allowed),
Metadata (retrieves information about the files), and Content
(retrieves the actual file content).
I haven't added the indirection tests yet, and the configuration
tests are still all stubs.
Diffstat (limited to 'lib/puppet/util')
-rw-r--r-- | lib/puppet/util/checksums.rb | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/lib/puppet/util/checksums.rb b/lib/puppet/util/checksums.rb new file mode 100644 index 000000000..6f6ea59b5 --- /dev/null +++ b/lib/puppet/util/checksums.rb @@ -0,0 +1,37 @@ +module Puppet::Util::Checksums + def md5(content) + require 'digest/md5' + Digest::MD5.hexdigest(content) + end + + def md5_file(filename) + require 'digest/md5' + + incr_digest = Digest::MD5.new() + File.open(filename, 'r') do |file| + file.each_line do |line| + incr_digest << line + end + end + + return incr_digest.hexdigest + end + + def sha1(content) + require 'digest/sha1' + Digest::SHA1.hexdigest(content) + end + + def sha1_file(filename) + require 'digest/sha1' + + incr_digest = Digest::SHA1.new() + File.open(filename, 'r') do |file| + file.each_line do |line| + incr_digest << line + end + end + + return incr_digest.hexdigest + end +end |