class Bosh::Cli::Versions::LocalArtifactStorage
Attributes
storage_dir[R]
Public Class Methods
new(storage_dir)
click to toggle source
# File lib/cli/versions/local_artifact_storage.rb, line 8 def initialize(storage_dir) @storage_dir = storage_dir end
Public Instance Methods
file_path(name)
click to toggle source
# File lib/cli/versions/local_artifact_storage.rb, line 36 def file_path(name) File.join(@storage_dir, name) end
get_file(sha)
click to toggle source
# File lib/cli/versions/local_artifact_storage.rb, line 23 def get_file(sha) destination = file_path(sha) unless File.exist?(destination) raise "Trying to retrieve non-existant file `#{destination}' with sha `#{sha}'" end File.expand_path(destination) end
has_file?(sha)
click to toggle source
# File lib/cli/versions/local_artifact_storage.rb, line 32 def has_file?(sha) File.exists?(file_path(sha)) end
put_file(sha, origin_file_path)
click to toggle source
# File lib/cli/versions/local_artifact_storage.rb, line 12 def put_file(sha, origin_file_path) destination = file_path(sha) unless File.exist?(origin_file_path) raise "Trying to store non-existant file `#{origin_file_path}' with sha `#{sha}'" end FileUtils.mkdir_p(File.dirname(destination)) FileUtils.cp(origin_file_path, destination, :preserve => true) File.expand_path(destination) end