lib/kindai/book_downloader.rb in kindai-1.5.1 vs lib/kindai/book_downloader.rb in kindai-1.6.0

- old
+ new

@@ -13,12 +13,13 @@ me.base_path = Dir.pwd me end def download - return false if self.has_file? create_directory + write_metadata + return false if self.has_file? download_spreads return true end def book_path @@ -32,9 +33,19 @@ def delete success = true FileUtils.rm_r(self.book_path) rescue success = false return success + end + + def write_metadata + open(metadata_path, 'w') {|f| + f.puts book.permalink_uri + } unless File.exists?(metadata_path) + end + + def metadata_path + File.join(book_path, 'metadata') end def has_file? File.directory?(self.book_path) && self.spread_downloaders.all?(&:has_file?) end