Delete() public method

public Delete ( Uri resourceUri, CancellationToken cancellationToken ) : System.Threading.Tasks.Task
resourceUri System.Uri
cancellationToken CancellationToken
return System.Threading.Tasks.Task
Esempio n. 1
0
        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);
                }
            }
        }
        static async Task SaveLargeRegistration(Storage storage, Uri registrationBaseAddress, IDictionary<string, IGraph> items, string existingRoot, Uri contentBaseAddress, int partitionSize, CancellationToken cancellationToken)
        {
            if (existingRoot != null)
            {
                JToken compacted = JToken.Parse(existingRoot);
                AddExistingItems(Utils.CreateGraph(compacted), items);
            }

            IList<Uri> cleanUpList = new List<Uri>();

            await SaveRegistration(storage, registrationBaseAddress, items, cleanUpList, null, contentBaseAddress, partitionSize, cancellationToken);

            // because there were multiple files some might now be irrelevant

            foreach (Uri uri in cleanUpList)
            {
                if (uri != storage.ResolveUri("index.json"))
                {
                    Console.WriteLine("DELETE: {0}", uri);
                    await storage.Delete(uri, cancellationToken);
                }
            }
        }
Esempio n. 3
0
 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);
     }
 }