Class: Puppet::FileBucketFile::File
- Inherits:
-
Indirector::Code
- Object
- Indirector::Terminus
- Indirector::Code
- Puppet::FileBucketFile::File
- Includes:
- Util::Checksums
- Defined in:
- lib/vendor/puppet/indirector/file_bucket_file/file.rb
Constant Summary
Constants included from Util
Util::AbsolutePathPosix, Util::AbsolutePathWindows
Constants included from Util::Docs
Instance Attribute Summary
Attributes included from Util::Docs
Instance Method Summary collapse
- #find(request) ⇒ Object
- #head(request) ⇒ Object
-
#initialize ⇒ File
constructor
A new instance of File.
- #save(request) ⇒ Object
Methods included from Util::Checksums
#checksum?, #ctime, #ctime_file, #md5, #md5_file, #md5_stream, #md5lite, #md5lite_file, #mtime, #mtime_file, #mtime_stream, #none, #none_file, #none_stream, #sha1, #sha1_file, #sha1_stream, #sha1lite, #sha1lite_file, #sumdata, #sumtype
Methods inherited from Indirector::Terminus
abstract_terminus?, const2name, #indirection, indirection_name, inherited, mark_as_abstract_terminus, #model, model, #name, name2const, register_terminus_class, terminus_class, terminus_classes, #terminus_type
Methods included from Util::InstanceLoader
#instance_docs, #instance_hash, #instance_load, #instance_loader, #instance_loading?, #loaded_instance, #loaded_instances
Methods included from Util
absolute_path?, activerecord_version, benchmark, binread, chuser, classproxy, #execfail, #execpipe, execute, execute_posix, execute_windows, logmethods, memory, path_to_uri, proxy, replace_file, safe_posix_fork, symbolize, symbolizehash, symbolizehash!, synchronize_on, thinmark, #threadlock, uri_to_path, wait_for_output, which, withumask
Methods included from Util::POSIX
#get_posix_field, #gid, #idfield, #methodbyid, #methodbyname, #search_posix_field, #uid
Methods included from Util::Docs
#desc, #dochook, #doctable, #markdown_definitionlist, #markdown_header, #nodoc?, #pad, scrub
Constructor Details
Instance Method Details
#find(request) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/vendor/puppet/indirector/file_bucket_file/file.rb', line 16 def find( request ) checksum, files_original_path = request_to_checksum_and_path( request ) dir_path = path_for(request.[:bucket_path], checksum) file_path = ::File.join(dir_path, 'contents') return nil unless ::File.exists?(file_path) return nil unless path_match(dir_path, files_original_path) if request.[:diff_with] hash_protocol = sumtype(checksum) file2_path = path_for(request.[:bucket_path], request.[:diff_with], 'contents') raise "could not find diff_with #{request.[:diff_with]}" unless ::File.exists?(file2_path) return `diff #{file_path.inspect} #{file2_path.inspect}` else contents = IO.binread(file_path) Puppet.info "FileBucket read #{checksum}" model.new(contents) end end |
#head(request) ⇒ Object
36 37 38 39 40 41 |
# File 'lib/vendor/puppet/indirector/file_bucket_file/file.rb', line 36 def head(request) checksum, files_original_path = request_to_checksum_and_path(request) dir_path = path_for(request.[:bucket_path], checksum) ::File.exists?(::File.join(dir_path, 'contents')) and path_match(dir_path, files_original_path) end |
#save(request) ⇒ Object
43 44 45 46 47 48 49 |
# File 'lib/vendor/puppet/indirector/file_bucket_file/file.rb', line 43 def save( request ) instance = request.instance checksum, files_original_path = request_to_checksum_and_path(request) save_to_disk(instance, files_original_path) instance.to_s end |