lib/mangos/book_updater.rb in mangos-0.2 vs lib/mangos/book_updater.rb in mangos-0.3

- old
+ new

@@ -8,17 +8,19 @@ end def update page_paths = find_page_paths - @book.key = Digest::SHA256.hexdigest(@path.to_s)[0..16] + @book.old_key = @book.key + @book.key = Digest::SHA256.hexdigest(@path.basename.to_s)[0..16] @book.page_paths = build_page_paths(page_paths) @book.pages = page_paths.length @book.path = @path.basename.to_s @book.published_on = @path.mtime.to_i @book.tags = Mangos::TagBreaker.new(@book.path).tags + fix_thumbnail_path if @package.migrate? Mangos::Thumbnailer.new(page_paths.first, thumbnail_path).generate end def find_page_paths image_paths = @path.children.select { |p| p.image? && !p.hidden? } @@ -29,7 +31,14 @@ Mangos::PagesDeflater.new(page_paths.map { |p| p.basename.to_s }).deflate end def thumbnail_path @package.thumbnails_path + "#{@book.key}.jpg" + end + + def fix_thumbnail_path + old_thumbnail_path = @package.thumbnails_path + "#{@book.old_key}.jpg" + if old_thumbnail_path.exist? && !thumbnail_path.exist? + old_thumbnail_path.rename(thumbnail_path) + end end end \ No newline at end of file