# File lib/puppet/network/handler/filebucket.rb, line 74
 74:         def addfile(contents, path, client = nil, clientip = nil)
 75:             if client
 76:                 contents = Base64.decode64(contents)
 77:             end
 78:             md5 = Digest::MD5.hexdigest(contents)
 79: 
 80:             bpath, bfile, pathpath = FileBucket.paths(@path,md5)
 81: 
 82:             # If the file already exists, just return the md5 sum.
 83:             if FileTest.exists?(bfile)
 84:                 # If verification is enabled, then make sure the text matches.
 85:                 if conflict_check?
 86:                     verify(contents, md5, bfile)
 87:                 end
 88:                 return md5
 89:             end
 90: 
 91:             # Make the directories if necessary.
 92:             unless FileTest.directory?(bpath)
 93:                 Puppet::Util.withumask(0007) do
 94:                     FileUtils.mkdir_p(bpath)
 95:                 end
 96:             end
 97: 
 98:             # Write the file to disk.
 99:             msg = "Adding %s(%s)" % [path, md5]
100:             msg += " from #{client}" if client
101:             self.info msg
102: 
103:             # ...then just create the file
104:             Puppet::Util.withumask(0007) do
105:                 File.open(bfile, File::WRONLY|File::CREAT, 0440) { |of|
106:                     of.print contents
107:                 }
108:             end
109: 
110:             # Write the path to the paths file.
111:             add_path(path, pathpath)
112: 
113:             return md5
114:         end