mirror of
https://github.com/hkalexling/Mango.git
synced 2025-08-02 10:55:30 -04:00
Merge pull request #258 from Leeingnyo/fix/fix-bug-on-scan
Fix bug on scanning
This commit is contained in:
commit
d7afd0969a
@ -136,8 +136,12 @@ class Library
|
|||||||
deleted_entry_ids: [] of String,
|
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_ids.select! do |title_id|
|
||||||
title = @title_hash[title_id]
|
title = @title_hash[title_id]
|
||||||
|
next false unless library_paths.includes? title.dir
|
||||||
existence = title.examine examine_context
|
existence = title.examine examine_context
|
||||||
unless existence
|
unless existence
|
||||||
examine_context["deleted_title_ids"].concat [title_id] +
|
examine_context["deleted_title_ids"].concat [title_id] +
|
||||||
@ -152,9 +156,7 @@ class Library
|
|||||||
end
|
end
|
||||||
|
|
||||||
cache = examine_context["cached_contents_signature"]
|
cache = examine_context["cached_contents_signature"]
|
||||||
(Dir.entries @dir)
|
library_paths
|
||||||
.select { |fn| !fn.starts_with? "." }
|
|
||||||
.map { |fn| File.join @dir, fn }
|
|
||||||
.select { |path| !(remained_title_dirs.includes? path) }
|
.select { |path| !(remained_title_dirs.includes? path) }
|
||||||
.select { |path| File.directory? path }
|
.select { |path| File.directory? path }
|
||||||
.map { |path| Title.new path, "", cache }
|
.map { |path| Title.new path, "", cache }
|
||||||
|
@ -102,7 +102,11 @@ class Title
|
|||||||
|
|
||||||
previous_titles_size = @title_ids.size
|
previous_titles_size = @title_ids.size
|
||||||
@title_ids.select! do |title_id|
|
@title_ids.select! do |title_id|
|
||||||
title = Library.default.get_title! title_id
|
title = Library.default.get_title title_id
|
||||||
|
unless title # for if data consistency broken
|
||||||
|
context["deleted_title_ids"].concat [title_id]
|
||||||
|
next false
|
||||||
|
end
|
||||||
existence = title.examine context
|
existence = title.examine context
|
||||||
unless existence
|
unless existence
|
||||||
context["deleted_title_ids"].concat [title_id] +
|
context["deleted_title_ids"].concat [title_id] +
|
||||||
@ -137,6 +141,18 @@ class Title
|
|||||||
Library.default.title_hash[title.id] = title
|
Library.default.title_hash[title.id] = title
|
||||||
@title_ids << title.id
|
@title_ids << title.id
|
||||||
is_titles_added = true
|
is_titles_added = true
|
||||||
|
|
||||||
|
# We think they are removed, but they are here!
|
||||||
|
# Cancel reserved jobs
|
||||||
|
revival_title_ids = [title.id] + title.deep_titles.map &.id
|
||||||
|
context["deleted_title_ids"].select! do |deleted_title_id|
|
||||||
|
!(revival_title_ids.includes? deleted_title_id)
|
||||||
|
end
|
||||||
|
revival_entry_ids = title.deep_entries.map &.id
|
||||||
|
context["deleted_entry_ids"].select! do |deleted_entry_id|
|
||||||
|
!(revival_entry_ids.includes? deleted_entry_id)
|
||||||
|
end
|
||||||
|
|
||||||
next
|
next
|
||||||
end
|
end
|
||||||
if is_supported_file path
|
if is_supported_file path
|
||||||
@ -145,6 +161,9 @@ class Title
|
|||||||
if entry.pages > 0 || entry.err_msg
|
if entry.pages > 0 || entry.err_msg
|
||||||
@entries << entry
|
@entries << entry
|
||||||
is_entries_added = true
|
is_entries_added = true
|
||||||
|
context["deleted_entry_ids"].select! do |deleted_entry_id|
|
||||||
|
entry.id != deleted_entry_id
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -167,7 +186,12 @@ class Title
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if @title_ids.size > 0 || @entries.size > 0
|
||||||
true
|
true
|
||||||
|
else
|
||||||
|
context["deleted_title_ids"].concat [@id]
|
||||||
|
false
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
alias SortContext = NamedTuple(username: String, opt: SortOptions)
|
alias SortContext = NamedTuple(username: String, opt: SortOptions)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user