Scan DirectoryEntry when init and examine

This commit is contained in:
Leeingnyo 2022-05-15 15:31:11 +09:00
parent 55ccd928a2
commit 3b3a0738e8

View File

@ -49,9 +49,14 @@ class Title
path = File.join dir, fn
if File.directory? path
title = Title.new path, @id, cache
next if title.entries.size == 0 && title.titles.size == 0
unless title.entries.size == 0 && title.titles.size == 0
Library.default.title_hash[title.id] = title
@title_ids << title.id
end
if DirectoryEntry.validate_directory_entry path
entry = DirectoryEntry.new path, self
@entries << entry if entry.pages > 0 || entry.err_msg
end
next
end
if is_supported_file path
@ -132,7 +137,7 @@ class Title
context["deleted_entry_ids"] << entry.id unless existence
existence
end
remained_entry_zip_paths = @entries.map &.path
remained_entry_paths = @entries.map &.path
is_titles_added = false
is_entries_added = false
@ -140,9 +145,22 @@ class Title
next if fn.starts_with? "."
path = File.join dir, fn
if File.directory? path
unless remained_entry_paths.includes? path
if DirectoryEntry.validate_directory_entry path
entry = DirectoryEntry.new path, self
if entry.pages > 0 || entry.err_msg
@entries << entry
is_entries_added = true
context["deleted_entry_ids"].select! do |deleted_entry_id|
entry.id != deleted_entry_id
end
end
end
end
next if remained_title_dirs.includes? path
title = Title.new path, @id, context["cached_contents_signature"]
next if title.entries.size == 0 && title.titles.size == 0
unless title.entries.size == 0 && title.titles.size == 0
Library.default.title_hash[title.id] = title
@title_ids << title.id
is_titles_added = true
@ -157,11 +175,12 @@ class Title
context["deleted_entry_ids"].select! do |deleted_entry_id|
!(revival_entry_ids.includes? deleted_entry_id)
end
end
next
end
if is_supported_file path
next if remained_entry_zip_paths.includes? path
next if remained_entry_paths.includes? path
entry = ZippedEntry.new path, self
if entry.pages > 0 || entry.err_msg
@entries << entry