Class: XcodeArchiveCache::ArtifactCache::LocalStorage

Inherits:
AbstractStorage show all
Defined in:
lib/artifact_cache/local_storage.rb

Instance Method Summary collapse

Constructor Details

#initialize(cache_dir_path) ⇒ LocalStorage



7
8
9
10
# File 'lib/artifact_cache/local_storage.rb', line 7

def initialize(cache_dir_path)
  @cache_dir_path = cache_dir_path
  @archiver = Archiver.new
end

Instance Method Details

#cached_artifact_path(node) ⇒ String



16
17
18
19
# File 'lib/artifact_cache/local_storage.rb', line 16

def cached_artifact_path(node)
  path = path_inside_cache_dir(node)
  File.exist?(path) ? path : nil
end

#store(node, path) ⇒ Object



24
25
26
27
28
29
30
31
32
33
# File 'lib/artifact_cache/local_storage.rb', line 24

def store(node, path)
  archive_path = path_inside_cache_dir(node)
  archive_directory = File.expand_path("..", archive_path)
  unless File.exist?(archive_directory)
    FileUtils.mkdir_p(archive_directory)
  end

  archiver.archive(path, archive_path)
  save_state(node, archive_path)
end