summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/puppet/network/client/dipper.rb20
-rwxr-xr-xlib/puppet/network/handler/filebucket.rb2
2 files changed, 15 insertions, 7 deletions
diff --git a/lib/puppet/network/client/dipper.rb b/lib/puppet/network/client/dipper.rb
index 2084e09f6..5ddb67db1 100644
--- a/lib/puppet/network/client/dipper.rb
+++ b/lib/puppet/network/client/dipper.rb
@@ -28,6 +28,17 @@ class Puppet::Network::Client::Dipper < Puppet::Network::Client
return @driver.addfile(contents,file)
end
+ # Retrieve a file by sum.
+ def getfile(sum)
+ if newcontents = @driver.getfile(sum)
+ unless local?
+ newcontents = Base64.decode64(newcontents)
+ end
+ return newcontents
+ end
+ return nil
+ end
+
# Restore the file
def restore(file,sum)
restore = true
@@ -42,18 +53,15 @@ class Puppet::Network::Client::Dipper < Puppet::Network::Client
end
if restore
- if newcontents = @driver.getfile(sum)
- unless local?
- newcontents = Base64.decode64(newcontents)
- end
+ if newcontents = getfile(sum)
tmp = ""
newsum = Digest::MD5.hexdigest(newcontents)
changed = nil
- unless FileTest.writable?(file)
+ if FileTest.exists?(file) and ! FileTest.writable?(file)
changed = ::File.stat(file).mode
::File.chmod(changed | 0200, file)
end
- ::File.open(file,::File::WRONLY|::File::TRUNC) { |of|
+ ::File.open(file, ::File::WRONLY|::File::TRUNC|::File::CREAT) { |of|
of.print(newcontents)
}
if changed
diff --git a/lib/puppet/network/handler/filebucket.rb b/lib/puppet/network/handler/filebucket.rb
index f0d389aea..705a4eee9 100755
--- a/lib/puppet/network/handler/filebucket.rb
+++ b/lib/puppet/network/handler/filebucket.rb
@@ -28,7 +28,7 @@ class Puppet::Network::Handler # :nodoc:
# this doesn't work for relative paths
def self.paths(base,md5)
dir = File.join(md5[0..7].split(""))
- basedir = File.join(base, dir)
+ basedir = File.join(base, dir, md5)
return [
basedir,
File.join(basedir, "contents"),