Class: Bosh::Cli::Versions::LocalArtifactStorage
- Inherits:
-
Object
- Object
- Bosh::Cli::Versions::LocalArtifactStorage
show all
- Defined in:
- lib/cli/versions/local_artifact_storage.rb
Defined Under Namespace
Classes: Sha1MismatchError
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
Returns a new instance of LocalArtifactStorage.
8
9
10
|
# File 'lib/cli/versions/local_artifact_storage.rb', line 8
def initialize(storage_dir)
@storage_dir = storage_dir
end
|
Instance Attribute Details
#storage_dir ⇒ Object
Returns the value of attribute storage_dir.
6
7
8
|
# File 'lib/cli/versions/local_artifact_storage.rb', line 6
def storage_dir
@storage_dir
end
|
Instance Method Details
#file_path(name) ⇒ Object
36
37
38
|
# File 'lib/cli/versions/local_artifact_storage.rb', line 36
def file_path(name)
File.join(@storage_dir, name)
end
|
#get_file(sha) ⇒ Object
23
24
25
26
27
28
29
30
|
# 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) ⇒ Boolean
32
33
34
|
# 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) ⇒ Object
12
13
14
15
16
17
18
19
20
21
|
# 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
|