This commit is contained in:
Leeingnyo 2021-09-15 01:17:44 +09:00
parent f4d7128b59
commit a3b2cdd372
3 changed files with 8 additions and 5 deletions

View File

@ -153,7 +153,8 @@ class Library
title = @title_hash[title_id]
existence = title.examine examine_context
unless existence
examine_context["deleted_title_ids"].concat [title_id] + title.deep_titles.map &.id
examine_context["deleted_title_ids"].concat [title_id] +
title.deep_titles.map &.id
examine_context["deleted_entry_ids"].concat title.deep_entries.map &.id
end
existence

View File

@ -102,7 +102,8 @@ class Title
title = Library.default.get_title! title_id
existence = title.examine context
unless existence
context["deleted_title_ids"].concat [title_id] + title.deep_titles.map &.id
context["deleted_title_ids"].concat [title_id] +
title.deep_titles.map &.id
context["deleted_entry_ids"].concat title.deep_entries.map &.id
end
existence

View File

@ -467,13 +467,14 @@ class Storage
end
# Limit mark targets with given arguments
def mark_unavailable(trash_ids_candidates : Array(String), trash_titles_candidates : Array(String))
def mark_unavailable(ids_candidates : Array(String),
titles_candidates : Array(String))
MainFiber.run do
get_db do |db|
# Detect dangling entry IDs
trash_ids = [] of String
db.query "select path, id from ids where id in " \
"(#{trash_ids_candidates.join "," { |i| "'#{i}'" }})" do |rs|
"(#{ids_candidates.join "," { |i| "'#{i}'" }})" do |rs|
rs.each do
path = rs.read String
fullpath = Path.new(path).expand(Config.current.library_path).to_s
@ -490,7 +491,7 @@ class Storage
# Detect dangling title IDs
trash_titles = [] of String
db.query "select path, id from titles where id in " \
"(#{trash_titles_candidates.join "," { |i| "'#{i}'" }})" do |rs|
"(#{titles_candidates.join "," { |i| "'#{i}'" }})" do |rs|
rs.each do
path = rs.read String
fullpath = Path.new(path).expand(Config.current.library_path).to_s