从 ResilientUtils 迁移到 Retrier
This commit is contained in:
1 parent
94ef3f8f8e
commit
0bdeb20c0e
3 files changed
+18
-82
No files matched your search
@@ -103,7 +103,7 @@ public static class DirectoryUtils {
|
||||
// 同一磁盘剪切,直接调用 Move(这只修改文件夹名,效率更高)
|
||||
Logger.Trace($"剪切文件夹到同一磁盘:{sourceFolder} → {destFolder}");
|
||||
DirectoryUtils.Delete(destFolder); // Move 要求此前不存在对应文件夹
|
||||
ResilientUtils.RetryOn<IOException>(() => {
|
||||
Retrier.Attempt(delay: _ => TimeSpan.FromMilliseconds(200), isRetryAllowed: ex => ex is IOException, action: _ => {
|
||||
FileUtils.SetReadOnly(sourceFolder, false);
|
||||
Directory.Move(PathUtils.ForApi(sourceFolder), PathUtils.ForApi(destFolder));
|
||||
});
|
||||
@@ -144,7 +144,7 @@ public static class DirectoryUtils {
|
||||
folder = PathUtils.ForApi(folder);
|
||||
foreach (string filePath in DirectoryUtils.EnumerateFiles(folder)) FileUtils.Delete(filePath); // 删除文件
|
||||
foreach (string str in DirectoryUtils.EnumerateDirectories(folder)) DeleteInternal(str); // 递归删除子文件夹
|
||||
ResilientUtils.RetryOn<IOException>(() => {
|
||||
Retrier.Attempt(delay: _ => TimeSpan.FromMilliseconds(200), isRetryAllowed: ex => ex is IOException, action: _ => {
|
||||
FileUtils.SetReadOnly(folder, false);
|
||||
Directory.Delete(folder, true);
|
||||
}); // 最终删除文件夹
|
||||
|
||||
Reference in new issue
Block a user