Created
August 13, 2010 05:02
-
-
Save kristoferjoseph/522327 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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