|
@@ -34,7 +34,24 @@ namespace TEAMModelOS.SDK.DI
|
|
|
{
|
|
|
await foreach (BlobItem item in client.GetBlobsAsync(BlobTraits.None, BlobStates.None, prefix))
|
|
|
{
|
|
|
- size += item.Properties.ContentLength;
|
|
|
+
|
|
|
+ if (item.Name.StartsWith("res/", StringComparison.OrdinalIgnoreCase) && item.Name.EndsWith(".htex", StringComparison.OrdinalIgnoreCase))
|
|
|
+ { continue; }
|
|
|
+ if (!prefix.Equals(item.Name))
|
|
|
+ {
|
|
|
+ //避免操作(1111) /1111/1111.json /1111111/11111.json
|
|
|
+ if (!prefix.EndsWith("/"))
|
|
|
+ {
|
|
|
+ if (item.Name.StartsWith(prefix + "/"))
|
|
|
+ {
|
|
|
+ size += item.Properties.ContentLength;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ size += item.Properties.ContentLength;
|
|
|
+ }
|
|
|
};
|
|
|
return size;
|
|
|
}
|
|
@@ -141,17 +158,18 @@ namespace TEAMModelOS.SDK.DI
|
|
|
BlobContainerClient bcc = client.GetBlobContainerClient(blobContainerName);
|
|
|
BlobBatchClient bbc = client.GetBlobBatchClient();
|
|
|
List<Uri> blobs = new List<Uri>();
|
|
|
+ List<Task<Azure.Response<bool>>> list = new List<Task<Response<bool>>>();
|
|
|
foreach (var prefix in prefixs) {
|
|
|
string px = prefix;
|
|
|
if (prefix.StartsWith("/")) {
|
|
|
px= prefix.Substring(1);
|
|
|
}
|
|
|
var items = bcc.GetBlobsAsync(BlobTraits.None, BlobStates.None, px);
|
|
|
+
|
|
|
await foreach (var item in items)
|
|
|
{
|
|
|
- Console.WriteLine(item.Name);
|
|
|
var urib = new UriBuilder(bcc.Uri);
|
|
|
- await bcc.GetBlobClient(item.Name).DeleteIfExistsAsync();
|
|
|
+
|
|
|
if (!prefix.Equals(item.Name))
|
|
|
{
|
|
|
//避免操作(1111) /1111/1111.json /1111111/11111.json
|
|
@@ -159,18 +177,36 @@ namespace TEAMModelOS.SDK.DI
|
|
|
{
|
|
|
if (item.Name.StartsWith(prefix+ "/")) {
|
|
|
string path =$"{ urib.Uri.AbsoluteUri }/{ item.Name}";
|
|
|
+ list.Add(bcc.GetBlobClient(item.Name).DeleteIfExistsAsync());
|
|
|
+ if (item.Name.StartsWith("res/") && item.Name.EndsWith("/index.json")) {
|
|
|
+ list.Add(bcc.GetBlobClient($"{prefix}.htex").DeleteIfExistsAsync());
|
|
|
+ list.Add(bcc.GetBlobClient($"{prefix}.HTEX").DeleteIfExistsAsync());
|
|
|
+ }
|
|
|
blobs.Add(new Uri(path));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
else {
|
|
|
string path = $"{ urib.Uri.AbsoluteUri }/{ item.Name}";
|
|
|
+ list.Add(bcc.GetBlobClient(item.Name).DeleteIfExistsAsync());
|
|
|
blobs.Add(new Uri(path));
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
};
|
|
|
}
|
|
|
+ if (list.Count <= 256)
|
|
|
+ {
|
|
|
+ await Task.WhenAll(list);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ int pages = (list.Count + 255) / 256; //256是批量操作最大值,pages = (total + max -1) / max;
|
|
|
+ for (int i = 0; i < pages; i++)
|
|
|
+ {
|
|
|
+ List<Task<Azure.Response<bool>>> lists = list.Skip((i) * 256).Take(256).ToList();
|
|
|
+ await Task.WhenAll(lists);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ /*
|
|
|
if (blobs.Count <= 256)
|
|
|
{
|
|
|
if (blobs.Count > 0) {
|
|
@@ -217,6 +253,7 @@ namespace TEAMModelOS.SDK.DI
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
|
+ */
|
|
|
}
|
|
|
catch(Exception ex )
|
|
|
{
|