anchor.diff:              {error, Reason}
       end.
   
  -get_feed_original_url(LocalName) ->
  -    % this will need to change for implementing paged feeds
  -    Feeds = podrec_util:get_env(feeds),
  -    case maps:get(LocalName, Feeds, undefined) of
  -        undefined -> {error, unknown_feed};
  -        OriginalUrl -> {ok, OriginalUrl}
  +get_feed_original_url(LocalName) when is_binary(LocalName) ->
  +    T = fun() -> mnesia:read(podrec_feed, LocalName) end,
  +    case mnesia:transaction(T) of
  +        {atomic, [Feed]} ->
  +            {ok, Feed#podrec_feed.orig_url};
  +        {atomic, []} ->
  +            ConfiguredFeeds = podrec_util:get_env(feeds),
  +            case maps:get(LocalName, ConfiguredFeeds, undefined) of
  +                undefined -> {error, unknown_feed};
  +                OriginalUrl ->
  +                    ok = add_feed_to_db(#podrec_feed{local_name=LocalName, orig_url=OriginalUrl}),
  +                    {ok, OriginalUrl}
  +            end
       end.
  +
  +add_feed_to_db(Feed) when is_record(Feed, podrec_feed) ->
  +    lager:info("adding ~p to database", [Feed#podrec_feed.local_name]),
  +    {atomic, ok} = mnesia:transaction(fun() -> mnesia:write(Feed) end),
  +    ok.
   
   
   % job entry functions
  
positive.code:     CachedPath = get_cached_file_path(LocalName),
      case exists_cached_file(CachedPath) of
          true ->
              case is_cached_file_recent(CachedPath) of
                  true ->
                      lager:info("Req:~p cache is recent", [LocalName]),
                      {ok, CachedPath};
  
negative.code: 
  -record(state, {jobs=#{}}).
  
  -record(podrec_feed, {local_name, orig_url, last_fetch}).
  
  -compile(export_all).
  
  