Fix NoStrategyError during artist url normalization (#3382).

Fixes a bug from 9a3824a. When an artist entry is saved, `ArtistUrl.normalize`
is called on every URL, which calls `Sources::Site.new(url)`. This
raised NoStrategyError when an artist entry contained URLs that weren't
recognized by any strategy.

This also caused `Fetch source data` to fail in certain cases when it
attempted to find the artist.
This commit is contained in:
evazion
2017-11-19 10:27:38 -06:00
parent fa22e419af
commit 40d0751e83
2 changed files with 11 additions and 1 deletions

View File

@@ -18,7 +18,7 @@ class ArtistUrl < ApplicationRecord
url = url.sub(%r!^http://pictures.hentai-foundry.com//!, "http://pictures.hentai-foundry.com/")
begin
url = Sources::Site.new(url).normalize_for_artist_finder!
rescue PixivApiClient::Error
rescue PixivApiClient::Error, Sources::Site::NoStrategyError
end
url = url.gsub(/\/+\Z/, "")
url + "/"
@@ -75,6 +75,8 @@ class ArtistUrl < ApplicationRecord
if !Sources::Site.new(normalized_url).normalized_for_artist_finder?
self.normalized_url = self.class.normalize(url)
end
rescue Sources::Site::NoStrategyError
self.normalized_url = self.class.normalize(url)
end
def initialize_normalized_url