lib/fontist/utils/cache.rb in fontist-1.5.0 vs lib/fontist/utils/cache.rb in fontist-1.5.1
- old
+ new
@@ -4,11 +4,11 @@
def fetch(key)
map = load_cache
return downloaded_path(map[key]) if cache_exist?(map[key])
generated_file = yield
- path = save_cache(generated_file, key, map)
+ path = save_cache(generated_file, key)
downloaded_path(path)
end
private
@@ -27,13 +27,16 @@
def cache_exist?(path)
path && File.exist?(Fontist.downloads_path.join(path))
end
- def save_cache(generated_file, key, map)
+ def save_cache(generated_file, key)
path = move_to_downloads(generated_file)
+
+ map = load_cache
map[key] = path
File.write(cache_map_path, YAML.dump(map))
+
path
end
def move_to_downloads(source)
create_downloads_directory