Rescan only if instance loaded

This commit is contained in:
Leeingnyo 2021-09-12 01:26:02 +09:00
parent 80e13abc4a
commit e6214ddc5d

View File

@ -29,22 +29,26 @@ class Library
zip_file.close zip_file.close
return return
end end
is_loaded = false
begin begin
instance_file.open do |content| instance_file.open do |content|
@@default = Library.from_yaml content @@default = Library.from_yaml content
end end
is_loaded = true
rescue e rescue e
Logger.error e Logger.error e
end end
zip_file.close zip_file.close
spawn do if is_loaded
start = Time.local spawn do
Library.default.scan start = Time.local
ms = (Time.local - start).total_milliseconds Library.default.scan
Logger.info "Re-scanned #{Library.default.title_ids.size} titles \ ms = (Time.local - start).total_milliseconds
in #{ms}ms" Logger.info "Re-scanned #{Library.default.title_ids.size} titles \
in #{ms}ms"
end
end end
end end