public async Task DeleteOldMirrorFiles() { var existingHashes = await GetHashesOnCDN(); var fromSql = await _sql.GetAllMirroredHashes(); foreach (var(hash, _) in fromSql.Where(s => s.Value)) { Utils.Log($"Removing {hash} from SQL it's no longer in the CDN"); if (!existingHashes.Contains(hash)) { await _sql.DeleteMirroredFile(hash); } } var toDelete = existingHashes.Where(h => !fromSql.ContainsKey(h)).ToArray(); using var client = await GetClient(); foreach (var hash in toDelete) { await _discord.Send(Channel.Spam, new DiscordMessage { Content = $"Removing mirrored file {hash}, as it's no longer in sql" }); Utils.Log($"Removing {hash} from the CDN it's no longer in SQL"); await client.DeleteDirectoryAsync(hash.ToHex()); } }