lib/right_scraper/main.rb in right_scraper-5.2.4 vs lib/right_scraper/main.rb in right_scraper-5.2.5

- old
+ new

@@ -129,12 +129,18 @@ # Retrieves the given repository. See #scrape for details. def retrieve(repo) errorlen = errors.size unless repo.kind_of?(::RightScraper::Repositories::Base) - repo = RightScraper::Repositories::Base.from_hash(::RightSupport::Data::Mash.new(repo)) + repo = ::RightSupport::Data::Mash.new(repo) + repository_hash = repo.delete(:repository_hash) # optional + repo = RightScraper::Repositories::Base.from_hash(repo) + if repository_hash && repository_hash != repo.repository_hash + raise RightScraper::Error, "Repository hash mismatch: #{repository_hash} != #{repo.repository_hash}" + end end + retriever = nil # 1. Retrieve the files @logger.operation(:retrieving, "from #{repo}") do # note that the retriever type may be unavailable but allow the @@ -168,10 +174,15 @@ errorlen = errors.size old_callback = @logger.callback options = ::RightSupport::Data::Mash.new(@options).merge(retrieved) repo = options[:repository] unless repo.kind_of?(::RightScraper::Repositories::Base) - repo = RightScraper::Repositories::Base.from_hash(::RightSupport::Data::Mash.new(repo)) + repo = ::RightSupport::Data::Mash.new(repo) + repository_hash = repo.delete(:repository_hash) # optional + repo = RightScraper::Repositories::Base.from_hash(repo) + if repository_hash && repository_hash != repo.repository_hash + raise RightScraper::Error, "Repository hash mismatch: #{repository_hash} != #{repo.repository_hash}" + end options[:repository] = repo end @logger.operation(:scraping, options[:repo_dir]) do scraper = ::RightScraper::Scrapers::Base.scraper(options) @resources += scraper.scrape