[fix] 修复BashUtil.RemoveDir在偶然情况下出现删除目录失败的问题。新增多次重试。
parent
d9ed27abfb
commit
d5b52cc8db
|
@ -4,6 +4,7 @@ using System.Diagnostics;
|
|||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace HybridCLR.Editor.Installer
|
||||
|
@ -67,16 +68,23 @@ namespace HybridCLR.Editor.Installer
|
|||
{
|
||||
return;
|
||||
}
|
||||
foreach (var file in Directory.GetFiles(dir))
|
||||
|
||||
int maxTryCount = 5;
|
||||
for (int i = 0; i < maxTryCount; ++i)
|
||||
{
|
||||
File.SetAttributes(file, FileAttributes.Normal);
|
||||
File.Delete(file);
|
||||
}
|
||||
foreach (var subDir in Directory.GetDirectories(dir))
|
||||
try
|
||||
{
|
||||
RemoveDir(subDir);
|
||||
if (Directory.Exists(dir))
|
||||
{
|
||||
Directory.Delete(dir, true);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
UnityEngine.Debug.LogError($"[BashUtil] RemoveDir:{dir} with exception:{e}. try count:{i}");
|
||||
Thread.Sleep(100);
|
||||
}
|
||||
}
|
||||
Directory.Delete(dir);
|
||||
}
|
||||
|
||||
public static void RecreateDir(string dir)
|
||||
|
|
Loading…
Reference in New Issue