mirror of
https://github.com/hkalexling/Mango.git
synced 2025-08-02 10:55:30 -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
|
||||
|
||||
@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)
|
||||
.select { |fn| !fn.starts_with? "." }
|
||||
.map { |fn| File.join @dir, fn }
|
||||
.select { |path| !(remained_title_dirs.includes? path) }
|
||||
.select { |path| File.directory? path }
|
||||
.map { |path| Title.new path, "" }
|
||||
.select { |title| !(title.entries.empty? && title.titles.empty?) }
|
||||
.sort! { |a, b| a.title <=> b.title }
|
||||
.tap { |_| @title_ids.clear }
|
||||
.each do |title|
|
||||
@title_hash[title.id] = title
|
||||
@title_ids << title.id
|
||||
|
@ -69,6 +69,12 @@ class Title
|
||||
end
|
||||
end
|
||||
|
||||
def examine : Bool
|
||||
return false unless Dir.exists? @dir
|
||||
signature = Dir.signature @dir
|
||||
return @signature == signature
|
||||
end
|
||||
|
||||
def to_slim_json : String
|
||||
JSON.build do |json|
|
||||
json.object do
|
||||
|
Loading…
x
Reference in New Issue
Block a user