From cc33fa659597ff0ebc0dbaa6f007106073005c7a Mon Sep 17 00:00:00 2001 From: Leeingnyo Date: Sun, 19 Dec 2021 01:18:31 +0900 Subject: [PATCH] Fix bug: remove titles not in root library anymore --- src/library/library.cr | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/library/library.cr b/src/library/library.cr index 93eac0c..2a5de7d 100644 --- a/src/library/library.cr +++ b/src/library/library.cr @@ -136,8 +136,12 @@ class Library deleted_entry_ids: [] of String, } + library_paths = (Dir.entries @dir) + .select { |fn| !fn.starts_with? "." } + .map { |fn| File.join @dir, fn } @title_ids.select! do |title_id| title = @title_hash[title_id] + next false unless library_paths.includes? title.dir existence = title.examine examine_context unless existence examine_context["deleted_title_ids"].concat [title_id] + @@ -152,9 +156,7 @@ class Library end cache = examine_context["cached_contents_signature"] - (Dir.entries @dir) - .select { |fn| !fn.starts_with? "." } - .map { |fn| File.join @dir, fn } + library_paths .select { |path| !(remained_title_dirs.includes? path) } .select { |path| File.directory? path } .map { |path| Title.new path, "", cache }