Skip to content

Commit

Permalink
Merge pull request #374 from LoopPerfect/fix/fetch-private
Browse files Browse the repository at this point in the history
adds git fallback in cacheOrApi to fix #373
  • Loading branch information
nikhedonia authored Jul 17, 2020
2 parents 6e7ff66 + e3e4e79 commit f95792c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
Binary file added buckaroo/.ionide/symbolCache.db
Binary file not shown.
13 changes: 12 additions & 1 deletion buckaroo/DefaultSourceExplorer.fs
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,22 @@ type DefaultSourceExplorer (console : ConsoleManager, downloadManager : Download
let fromFileCache url revision path =
gitManager.GetFile url revision path |> toOptional


// We fetch from cache or api if possible.
// However fetching from api might be not feasable if credentials are required.
// In such case we fallback to git and try to find the requested commit.
let cacheOrApi (api, url : string, rev : string, path : string) = async {
let! cached = fromFileCache url rev path
match cached with
| Some data -> return data
| None -> return! api rev path
| None ->
match! (api rev path |> Async.Catch) with
| Choice1Of2 result ->
return result
| Choice2Of2 error ->
logger.Trace("failed to fetch file using api, falling back to git")
do! gitManager.FindCommit url rev None
return! fromFileCache url rev path |> Async.map (Option.getOrRaise <| error)
}

let extractFileFromHttp (source : HttpLocation) (filePath : string) = async {
Expand Down

0 comments on commit f95792c

Please sign in to comment.