User 'FileHelper.is_image?' to check wether a link is poiting to an image

This commit is contained in:
Régis Hanol 2017-06-22 12:54:42 +02:00
parent ca539854c8
commit 2e7753c27f
1 changed files with 1 additions and 1 deletions

View File

@ -64,7 +64,7 @@ module Jobs
# Special case: Images
# If the link is to an image, put the filename as the title
if topic_link.url =~ /\.(jpg|gif|png)$/
if FileHelper.is_image?(topic_link.url)
uri = URI(topic_link.url)
filename = File.basename(uri.path)
crawled = (TopicLink.where(id: topic_link.id).update_all(["title = ?, crawled_at = CURRENT_TIMESTAMP", filename]) == 1)