Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kristoferjoseph/522327 to your computer and use it in GitHub Desktop.
Save kristoferjoseph/522327 to your computer and use it in GitHub Desktop.
def handle_project_path path
project_path = File.expand_path(path)
project_hash = MD5.digest(project_path)
project_cache = File.join(tmp, project_hash)
swcs = FileUtils["#{project_path}/**/*.swc"]
handled_swc_paths = []
swcs.each do |swc|
handled_swc_paths << handle_swc(project_cache, swc)
end
remove_unused_cached_swcs handled_swc_paths
end
def remove_unused_cached_swcs handled_swc_paths
cached_swcs = FileUtils["#{project_cache}/*"]
cached_swcs.each do |cached_swc|
if(!handled_swc_paths.includes?(cached_swc))
FileUtils.rm cached_swc
end
end
end
def handle_swc cached_project, swc
swc_hash = MD5.digest(File.read(swc))
swc_path = File.join(cached_project, swc_hash)
if(!File.exists?(swc_path))
create_swc_cache(swc_path, swc)
end
swc_path
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment