Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/twbs/bootstrap-sass.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGleb Mazovetskiy <glex.spb@gmail.com>2014-06-26 20:52:59 +0400
committerGleb Mazovetskiy <glex.spb@gmail.com>2014-06-26 20:52:59 +0400
commitf76c5ee292e6fca69172b945da25629e893e9373 (patch)
treee7f0d95ff8541ea22547fb78d267668425142f68
parent1766234e9a643733dab8d893b5fb4c1bf76d726b (diff)
converter: improve cache
-rw-r--r--tasks/converter/network.rb26
1 files changed, 12 insertions, 14 deletions
diff --git a/tasks/converter/network.rb b/tasks/converter/network.rb
index 1fcb51c8..4b0c8e7e 100644
--- a/tasks/converter/network.rb
+++ b/tasks/converter/network.rb
@@ -8,19 +8,16 @@ class Converter
def read_files(path, files)
full_path = "https://raw.githubusercontent.com/#@repo/#@branch_sha/#{path}"
- if (contents = read_cached_files(path, files))
- log_http_get_files files, full_path, true
- else
- log_http_get_files files, full_path, false
- contents = {}
- files.map do |name|
- Thread.start {
- content = open("#{full_path}/#{name}").read
- Thread.exclusive { contents[name] = content }
- }
- end.each(&:join)
- write_cached_files path, contents
- end
+ contents = read_cached_files(path, files)
+ log_http_get_files contents.keys, full_path, true if contents.keys
+ files -= contents.keys
+ log_http_get_files files, full_path, false
+ files.map do |name|
+ Thread.start {
+ content = open("#{full_path}/#{name}").read
+ Thread.exclusive { write_cached_files path, name => content }
+ }
+ end.each(&:join)
contents
end
@@ -29,7 +26,8 @@ class Converter
contents = {}
if File.directory?(full_path)
files.each do |name|
- contents[name] = File.read("#{full_path}/#{name}", mode: 'rb') || ''
+ path = "#{full_path}/#{name}"
+ contents[name] = File.read(path, mode: 'rb') if File.exists?(path)
end
contents
end