--- alexandria-book-collection-manager-0.7.4/lib/alexandria/library_store.rb.broken_yaml 2019-10-25 01:20:07.000000000 +0900
+++ alexandria-book-collection-manager-0.7.4/lib/alexandria/library_store.rb 2020-01-03 17:38:07.340338529 +0900
@@ -48,8 +48,23 @@ module Alexandria
Dir["*" + Library::EXT[:book]].each do |filename|
test[1] = filename if (test[0]).zero?
+ book_valid_p = true
+
unless File.size? test[1]
log.warn { "Book file #{test[1]} was empty" }
+ book_valid_p = false
+ end
+
+ if book_valid_p
+ begin
+ book = self.regularize_book_from_yaml(test[1])
+ rescue Psych::SyntaxError => e
+ log.warn "Book file #{test[1]} could not be parsed"
+ book_valid_p = false
+ end
+ end
+
+ if not book_valid_p
md = /([\dxX]{10,13})#{Library::EXT[:book]}/.match(filename)
if md
file_isbn = md[1]
@@ -60,7 +75,7 @@ module Alexandria
end
next
end
- book = regularize_book_from_yaml(test[1])
+
old_isbn = book.isbn
old_pub_year = book.publishing_year
begin
@@ -193,6 +208,8 @@ module Alexandria
# TODO: Ensure book loading passes through Book#initialize
book = YAML.safe_load(text, permitted_classes: [Book, Time])
+ # TODO: Need check if this can be removed
+ # book = YAML.load(Syck::unescape(text))
unless book.isbn.class == String
# HACK