mirror of
https://github.com/hkalexling/Mango.git
synced 2025-08-03 03:15:31 -04:00
Examine titles and recycle them
This commit is contained in:
parent
0a90e3b333
commit
eb3e37b950
@ -144,14 +144,20 @@ class Library
|
|||||||
|
|
||||||
storage = Storage.new auto_close: false
|
storage = Storage.new auto_close: false
|
||||||
|
|
||||||
|
@title_ids.select! do |title_id|
|
||||||
|
title = @title_hash[title_id]
|
||||||
|
title.examine
|
||||||
|
end
|
||||||
|
remained_title_dirs = @title_ids.map { |id| title_hash[id].dir }
|
||||||
|
|
||||||
(Dir.entries @dir)
|
(Dir.entries @dir)
|
||||||
.select { |fn| !fn.starts_with? "." }
|
.select { |fn| !fn.starts_with? "." }
|
||||||
.map { |fn| File.join @dir, fn }
|
.map { |fn| File.join @dir, fn }
|
||||||
|
.select { |path| !(remained_title_dirs.includes? path) }
|
||||||
.select { |path| File.directory? path }
|
.select { |path| File.directory? path }
|
||||||
.map { |path| Title.new path, "" }
|
.map { |path| Title.new path, "" }
|
||||||
.select { |title| !(title.entries.empty? && title.titles.empty?) }
|
.select { |title| !(title.entries.empty? && title.titles.empty?) }
|
||||||
.sort! { |a, b| a.title <=> b.title }
|
.sort! { |a, b| a.title <=> b.title }
|
||||||
.tap { |_| @title_ids.clear }
|
|
||||||
.each do |title|
|
.each do |title|
|
||||||
@title_hash[title.id] = title
|
@title_hash[title.id] = title
|
||||||
@title_ids << title.id
|
@title_ids << title.id
|
||||||
|
@ -69,6 +69,12 @@ class Title
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def examine : Bool
|
||||||
|
return false unless Dir.exists? @dir
|
||||||
|
signature = Dir.signature @dir
|
||||||
|
return @signature == signature
|
||||||
|
end
|
||||||
|
|
||||||
def to_slim_json : String
|
def to_slim_json : String
|
||||||
JSON.build do |json|
|
JSON.build do |json|
|
||||||
json.object do
|
json.object do
|
||||||
|
Loading…
x
Reference in New Issue
Block a user