# File lib/puppet/file_bucket/dipper.rb, line 63
63:   def restore(file,sum)
64:     restore = true
65:     if FileTest.exists?(file)
66:       cursum = Digest::MD5.hexdigest(::File.read(file))
67: 
68:       # if the checksum has changed...
69:       # this might be extra effort
70:       if cursum == sum
71:         restore = false
72:       end
73:     end
74: 
75:     if restore
76:       if newcontents = getfile(sum)
77:         tmp = ""
78:         newsum = Digest::MD5.hexdigest(newcontents)
79:         changed = nil
80:         if FileTest.exists?(file) and ! FileTest.writable?(file)
81:           changed = ::File.stat(file).mode
82:           ::File.chmod(changed | 0200, file)
83:         end
84:         ::File.open(file, ::File::WRONLY|::File::TRUNC|::File::CREAT) { |of|
85:           of.print(newcontents)
86:         }
87:         ::File.chmod(changed, file) if changed
88:       else
89:         Puppet.err "Could not find file with checksum #{sum}"
90:         return nil
91:       end
92:       return newsum
93:     else
94:       return nil
95:     end
96:   end