         delta_import(id)
 
       {:error, message} ->
-        podcast = Repo.get(Podcast, id)
-
-        Podcast.changeset(podcast, %{failure_count: (podcast.failure_count || 0) + 1})
-        |> Repo.update([force: true])
-
-        if podcast.failure_count == 9 do
-          Podcast.changeset(podcast, %{retired: true})
-          |> Repo.update([force: true])
-        end
-
+        increase_failure_count(id)
         {:error, message}
     end
   end

    case RssFeed.import_to_map(feed.self_link_url, id) do
      {:ok, map} ->
        Persistor.delta_import(map, id)
        unpause(id)
        {:ok, "Podcast importet"}

      {:redirect, redirect_target} ->

  end


  def unpause_and_reset_failure_count(id) do
    Repo.get(Podcast, id)
    |> PanWeb.Podcast.changeset(%{update_paused: false,
                                  failure_count: 0})
    |> Repo.update([force: true])
  end


  def increase_failure_count(id) do
    podcast = Repo.get(Podcast, id)

    Podcast.changeset(podcast, %{failure_count: (podcast.failure_count || 0) + 1})
    |> Repo.update([force: true])

    if podcast.failure_count == 9 do
      Podcast.changeset(podcast, %{retired: true})
      |> Repo.update([force: true])
    end
  end


