mirror of
https://github.com/hkalexling/Mango.git
synced 2026-04-24 00:03:12 -04:00
Add config 'forcely_yield_count'
the default value 1000 would make a fiber yield on each 4ms on SSD Apply yield counter in Dir.contents_signauture Use contents_signature cache in Title.new
This commit is contained in:
@@ -54,9 +54,11 @@ class Dir
|
||||
# Rescan conditions:
|
||||
# - When a file added, moved, removed, renamed (including which in nested
|
||||
# directories)
|
||||
def self.contents_signature(dirname, cache = {} of String => String) : String
|
||||
return cache[dirname] if !cache.nil? && cache[dirname]?
|
||||
Fiber.yield # Yield first
|
||||
def self.contents_signature(dirname,
|
||||
cache = {} of String => String,
|
||||
counter : YieldCounter? = nil) : String
|
||||
return cache[dirname] if cache[dirname]?
|
||||
counter.count_and_yield unless counter.nil?
|
||||
signatures = [] of String
|
||||
self.open dirname do |dir|
|
||||
dir.entries.sort.each do |fn|
|
||||
@@ -69,10 +71,11 @@ class Dir
|
||||
# supported file
|
||||
signatures << fn if is_supported_file fn
|
||||
end
|
||||
counter.count_and_yield unless counter.nil?
|
||||
end
|
||||
end
|
||||
hash = Digest::SHA1.hexdigest(signatures.join)
|
||||
cache[dirname] = hash unless cache.nil?
|
||||
cache[dirname] = hash
|
||||
hash
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user