Skip to content

Commit

Permalink
Rescan only if instance loaded
Browse files Browse the repository at this point in the history
  • Loading branch information
Leeingnyo committed Sep 11, 2021
1 parent 80e13ab commit e6214dd
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/library/library.cr
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,26 @@ class Library
zip_file.close
return
end
is_loaded = false
begin
instance_file.open do |content|
@@default = Library.from_yaml content
end
is_loaded = true
rescue e
Logger.error e
end

zip_file.close

spawn do
start = Time.local
Library.default.scan
ms = (Time.local - start).total_milliseconds
Logger.info "Re-scanned #{Library.default.title_ids.size} titles \
in #{ms}ms"
if is_loaded
spawn do
start = Time.local
Library.default.scan
ms = (Time.local - start).total_milliseconds
Logger.info "Re-scanned #{Library.default.title_ids.size} titles \
in #{ms}ms"
end
end
end

Expand Down

0 comments on commit e6214dd

Please sign in to comment.