Skip to content

Commit f95792c

Browse files
authored
Merge pull request #374 from LoopPerfect/fix/fetch-private
adds git fallback in cacheOrApi to fix #373
2 parents 6e7ff66 + e3e4e79 commit f95792c

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

buckaroo/.ionide/symbolCache.db

1.93 MB
Binary file not shown.

buckaroo/DefaultSourceExplorer.fs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,22 @@ type DefaultSourceExplorer (console : ConsoleManager, downloadManager : Download
1313
let fromFileCache url revision path =
1414
gitManager.GetFile url revision path |> toOptional
1515

16+
17+
// We fetch from cache or api if possible.
18+
// However fetching from api might be not feasable if credentials are required.
19+
// In such case we fallback to git and try to find the requested commit.
1620
let cacheOrApi (api, url : string, rev : string, path : string) = async {
1721
let! cached = fromFileCache url rev path
1822
match cached with
1923
| Some data -> return data
20-
| None -> return! api rev path
24+
| None ->
25+
match! (api rev path |> Async.Catch) with
26+
| Choice1Of2 result ->
27+
return result
28+
| Choice2Of2 error ->
29+
logger.Trace("failed to fetch file using api, falling back to git")
30+
do! gitManager.FindCommit url rev None
31+
return! fromFileCache url rev path |> Async.map (Option.getOrRaise <| error)
2132
}
2233

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

0 commit comments

Comments
 (0)