Amazon.EC2.Import.DiskImageImporter.RemoveUploadedArtifacts C# (CSharp) Метод

RemoveUploadedArtifacts() приватный Метод

Removes the manifest and iterates through the parts list to see which parts had been completed when failures occur and removes those objects to avoid storage cost to the user (if the user retries the command, a different root key guid will be generated leading to potential orphans).
private RemoveUploadedArtifacts ( string manifestFileKey, IEnumerable partsList ) : bool
manifestFileKey string The object key of the manifest file.
partsList IEnumerable The set of parts that should have been uploaded
Результат bool
        bool RemoveUploadedArtifacts(string manifestFileKey, IEnumerable<ImageFilePart> partsList)
        {
            var allRemoved = true;

            try
            {
                S3Client.Delete(this.BucketName, manifestFileKey, null);
            }
            catch (Exception)
            {
                allRemoved = false;
            }

            var keysToDelete = (from part in partsList where part.UploadCompleted select part.Key).ToList();

            var keyIndex = 0;
            while (keyIndex < keysToDelete.Count)
            {
                var batchOfKeys = new List<string>();
                while (keyIndex < keysToDelete.Count && batchOfKeys.Count <= 1000)
                {
                    keysToDelete.Add(keysToDelete[keyIndex++]);
                }

                try
                {
                    S3Client.Deletes(this.BucketName, batchOfKeys, null);
                }
                catch
                {
                    allRemoved = false;
                }
            }

            return allRemoved;
        }