From d5b52cc8db799fca2399d91581c4023e8c5319ad Mon Sep 17 00:00:00 2001 From: walon Date: Wed, 1 Nov 2023 19:36:42 +0800 Subject: [PATCH] =?UTF-8?q?[fix]=20=E4=BF=AE=E5=A4=8DBashUtil.RemoveDir?= =?UTF-8?q?=E5=9C=A8=E5=81=B6=E7=84=B6=E6=83=85=E5=86=B5=E4=B8=8B=E5=87=BA?= =?UTF-8?q?=E7=8E=B0=E5=88=A0=E9=99=A4=E7=9B=AE=E5=BD=95=E5=A4=B1=E8=B4=A5?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98=E3=80=82=E6=96=B0=E5=A2=9E=E5=A4=9A?= =?UTF-8?q?=E6=AC=A1=E9=87=8D=E8=AF=95=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Editor/Installer/BashUtil.cs | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/Editor/Installer/BashUtil.cs b/Editor/Installer/BashUtil.cs index 9d69c6c..428275b 100644 --- a/Editor/Installer/BashUtil.cs +++ b/Editor/Installer/BashUtil.cs @@ -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); + try + { + 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); + } } - foreach (var subDir in Directory.GetDirectories(dir)) - { - RemoveDir(subDir); - } - Directory.Delete(dir); } public static void RecreateDir(string dir)