Exemplo n.º 1
0
        public Task <string> GetPackage(string packageId, string packageVersion) =>
        recorder.RecordArtifact(
            "nuget/" + name + "/" + packageId + "/" + packageVersion + "/" + packageId + "." + packageVersion + ".nupkg",
            async cacheDir => {
            var finalFileName = Path.Combine(cacheDir, "dependencies", "nuget", name, packageId, packageVersion, packageId + "." + packageVersion + ".nupkg");

            await Cache.CacheDownload(cacheDir, finalFileName, async tempFile => {
                var url = await NuGetPackageBaseAddress();
                if (!url.EndsWith("/"))
                {
                    url += "/";
                }
                url += packageId + "/" + packageVersion + "/" + packageId + "." + packageVersion + ".nupkg";

                await HttpUtil.FetchFile(url, tempFile);
            });

            return(finalFileName);
        }
            );
Exemplo n.º 2
0
        public Task <string> GetArtifact(string path) =>
        recorder.RecordArtifact("maven/" + name + "/" + path, async cacheDir => {
            var finalFileName = Path.Combine(cacheDir, "dependencies", mode, path);

            await Cache.CacheDownload(cacheDir, finalFileName, async tempFile => {
                var url = serverBaseUrl;
                if (!url.EndsWith("/"))
                {
                    url += "/";
                }
                url += path;

                try {
                    await HttpUtil.FetchFile(url, tempFile);
                }
                catch (WebException ex) when((ex.Response as HttpWebResponse)?.StatusCode == HttpStatusCode.NotFound)
                {
                    throw new HttpErrorCodeException(HttpStatusCode.NotFound);
                }
            });

            return(finalFileName);
        });