|
@@ -168,45 +168,55 @@ namespace TEAMModelOS.SDK.DI
|
|
if (prefix.StartsWith("/")) {
|
|
if (prefix.StartsWith("/")) {
|
|
px= prefix.Substring(1);
|
|
px= prefix.Substring(1);
|
|
}
|
|
}
|
|
- var items = bcc.GetBlobsAsync(BlobTraits.None, BlobStates.None, px);
|
|
|
|
-
|
|
|
|
- await foreach (var item in items)
|
|
|
|
- {
|
|
|
|
- var urib = new UriBuilder(bcc.Uri);
|
|
|
|
-
|
|
|
|
- if (!prefix.Equals(item.Name))
|
|
|
|
|
|
+ //目录必须有两层以上,避免删除根目录所有的。
|
|
|
|
+ var pxlen= px.Split("/");
|
|
|
|
+ if (pxlen.Length >=2) {
|
|
|
|
+ var items = bcc.GetBlobsAsync(BlobTraits.None, BlobStates.None, px);
|
|
|
|
+ await foreach (var item in items)
|
|
{
|
|
{
|
|
- //避免操作(1111) /1111/1111.json /1111111/11111.json
|
|
|
|
- if (!prefix.EndsWith("/"))
|
|
|
|
|
|
+ var urib = new UriBuilder(bcc.Uri);
|
|
|
|
+
|
|
|
|
+ if (!prefix.Equals(item.Name))
|
|
{
|
|
{
|
|
- 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());
|
|
|
|
|
|
+ //避免操作(1111) /1111/1111.json /1111111/11111.json
|
|
|
|
+ if (!prefix.EndsWith("/"))
|
|
|
|
+ {
|
|
|
|
+ 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));
|
|
}
|
|
}
|
|
- 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
|
|
|
|
+ {
|
|
|
|
+ string path = $"{urib.Uri.AbsoluteUri}/{item.Name}";
|
|
|
|
+ list.Add(bcc.GetBlobClient(item.Name).DeleteIfExistsAsync());
|
|
|
|
+ blobs.Add(new Uri(path));
|
|
|
|
+ }
|
|
|
|
+ };
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|
|
- else {
|
|
|
|
- int pages = (list.Count + 255) / 256; //256是批量操作最大值,pages = (total + max -1) / max;
|
|
|
|
- for (int i = 0; i < pages; i++)
|
|
|
|
|
|
+ if (list.Count > 0) {
|
|
|
|
+ if (list.Count <= 256)
|
|
|
|
+ {
|
|
|
|
+ await Task.WhenAll(list);
|
|
|
|
+ }
|
|
|
|
+ else
|
|
{
|
|
{
|
|
- List<Task<Azure.Response<bool>>> lists = list.Skip((i) * 256).Take(256).ToList();
|
|
|
|
- await Task.WhenAll(lists);
|
|
|
|
|
|
+ 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;
|
|
return true;
|