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:
83: if FileTest.exists?(bfile)
84:
85: if conflict_check?
86: verify(contents, md5, bfile)
87: end
88: return md5
89: end
90:
91:
92: unless FileTest.directory?(bpath)
93: Puppet::Util.withumask(0007) do
94: FileUtils.mkdir_p(bpath)
95: end
96: end
97:
98:
99: msg = "Adding %s(%s)" % [path, md5]
100: msg += " from #{client}" if client
101: self.info msg
102:
103:
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:
111: add_path(path, pathpath)
112:
113: return md5
114: end