private Task <PackageMonitoringStatus> GetPackageAsync(CatalogStorage storage, string fileName, CancellationToken token) { if (!storage.Exists(fileName)) { return(Task.FromResult <PackageMonitoringStatus>(null)); } return(GetPackageAsync(storage, storage.ResolveUri(fileName), token)); }
async Task UpdateMetadata(Storage storage, Action<HashSet<NuGetVersion>> updateAction, CancellationToken cancellationToken) { string relativeAddress = "index.json"; var resourceUri = new Uri(storage.BaseAddress, relativeAddress); HashSet<NuGetVersion> versions = GetVersions(await storage.LoadString(resourceUri, cancellationToken)); updateAction(versions); List<NuGetVersion> result = new List<NuGetVersion>(versions); if (result.Any()) { // Store versions (sorted) result.Sort(); await storage.Save(resourceUri, CreateContent(result.Select((v) => v.ToString())), cancellationToken); } else { // Remove versions file if no versions are present if (storage.Exists(relativeAddress)) { await storage.Delete(resourceUri, cancellationToken); } } }
public override bool Exists(string fileName) { return(_primaryStorage.Exists(fileName)); }
private async Task DeleteNupkg(Storage storage, string id, string version, CancellationToken cancellationToken) { string relativeAddress = string.Format("{1}/{0}.{1}.nupkg", id, version); Uri nupkgUri = new Uri(storage.BaseAddress, relativeAddress); if (storage.Exists(relativeAddress)) { await storage.Delete(nupkgUri, cancellationToken); } }