diff --git a/TGS.Server/Helpers.cs b/TGS.Server/Helpers.cs
index 7cff312bca..49280d7e5d 100644
--- a/TGS.Server/Helpers.cs
+++ b/TGS.Server/Helpers.cs
@@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.IO;
-using System.Threading.Tasks;
namespace TGS.Server
{
@@ -33,7 +32,7 @@ namespace TGS.Server
/// The directory to delete
/// If , an empty will remain instead of being deleted fully. Incompatible with
/// If any files or directories in the root level of match anything in this of s, they won't be deleted. Incompatible with
- public static async void DeleteDirectory(string path, bool ContentsOnly = false, IList excludeRoot = null)
+ public static void DeleteDirectory(string path, bool ContentsOnly = false, IList excludeRoot = null)
{
var di = new DirectoryInfo(path);
if (!di.Exists)
@@ -43,7 +42,7 @@ namespace TGS.Server
excludeRoot[I] = excludeRoot[I].ToLower();
if (CheckDeleteSymlinkDir(di))
return;
- await NormalizeAndDelete(di, excludeRoot, false);
+ NormalizeAndDelete(di, excludeRoot);
if (!ContentsOnly)
{
if (excludeRoot != null && excludeRoot.Count > 0)
@@ -73,31 +72,24 @@ namespace TGS.Server
///
/// of the directory to empty
/// Lowercase file and directory names to skip while emptying this level. Not passed forward
- /// If , will be deleted before the function exits
- static async Task NormalizeAndDelete(DirectoryInfo dir, IList excludeRoot, bool deleteRoot)
+ static void NormalizeAndDelete(DirectoryInfo dir, IList excludeRoot)
{
- var tasks = new List { Task.Factory.StartNew(() =>
- {
- foreach (var file in dir.GetFiles())
- {
- if (excludeRoot != null && excludeRoot.Contains(file.Name.ToLower()))
- continue;
- file.Attributes = FileAttributes.Normal;
- file.Delete();
- }
- }) };
-
foreach (var subDir in dir.GetDirectories())
{
if (excludeRoot != null && excludeRoot.Contains(subDir.Name.ToLower()))
continue;
if (CheckDeleteSymlinkDir(subDir))
continue;
- tasks.Add(NormalizeAndDelete(subDir, null, true));
+ NormalizeAndDelete(subDir, null);
+ subDir.Delete(true);
+ }
+ foreach (var file in dir.GetFiles())
+ {
+ if (excludeRoot != null && excludeRoot.Contains(file.Name.ToLower()))
+ continue;
+ file.Attributes = FileAttributes.Normal;
+ file.Delete();
}
- await Task.WhenAll(tasks);
- if(deleteRoot)
- dir.Delete(true);
}
///
@@ -107,7 +99,7 @@ namespace TGS.Server
/// The destination directory
/// List of files and directories to ignore while copying
/// If no error will be thrown if does not exist
- public static async void CopyDirectory(string sourceDirName, string destDirName, IList ignore = null, bool ignoreIfNotExists = false)
+ public static void CopyDirectory(string sourceDirName, string destDirName, IList ignore = null, bool ignoreIfNotExists = false)
{
IList realIgnore;
if (ignore != null)
@@ -118,7 +110,7 @@ namespace TGS.Server
}
else
realIgnore = null;
- await CopyDirectoryImpl(sourceDirName, destDirName, realIgnore, ignoreIfNotExists);
+ CopyDirectoryImpl(sourceDirName, destDirName, realIgnore, ignoreIfNotExists);
}
///
@@ -128,7 +120,7 @@ namespace TGS.Server
/// The destination directory
/// List of lowercase files and directories to ignore while copying
/// If no error will be thrown if does not exist
- static async Task CopyDirectoryImpl(string sourceDirName, string destDirName, IList ignore, bool ignoreIfNotExists) {
+ static void CopyDirectoryImpl(string sourceDirName, string destDirName, IList ignore, bool ignoreIfNotExists) {
// If the destination directory doesn't exist, create it.
if (!Directory.Exists(destDirName))
{
@@ -158,16 +150,14 @@ namespace TGS.Server
file.CopyTo(temppath, true);
}
- var tasks = new List();
// copy them and their contents to new location.
foreach (DirectoryInfo subdir in dirs)
{
if (ignore != null && ignore.Contains(subdir.Name.ToLower()))
continue;
string temppath = Path.Combine(destDirName, subdir.Name);
- tasks.Add(CopyDirectoryImpl(subdir.FullName, temppath, ignore, false));
+ CopyDirectoryImpl(subdir.FullName, temppath, ignore, false);
}
- await Task.WhenAll(tasks);
}
///