public void ImportSettings(BuildType buildType)
{
using (new WurmAssistantGateway(AppContext.WaGatewayErrorMessage))
{
using (var tempDirMan = new TempDirManager())
{
var tempDir = tempDirMan.GetHandle();
var dataDir = new DirectoryInfo(DataDirPath);
var tempBackupDir = new DirectoryInfo(Path.Combine(tempDir.FullName, dataDir.Name));
DirectoryEx.DirectoryCopyRecursive(dataDir.FullName, tempBackupDir.FullName);
try
{
dataDir.Delete(true);
var otherBuildDirPath = AppContext.GetDataDir(buildType);
DirectoryEx.DirectoryCopyRecursive(otherBuildDirPath, dataDir.FullName);
}
catch (Exception)
{
TransientHelper.Compensate(() => dataDir.Delete(true),
retryDelay: TimeSpan.FromSeconds(5));
TransientHelper.Compensate(() => DirectoryEx.DirectoryCopyRecursive(tempBackupDir.FullName, dataDir.FullName),
retryDelay: TimeSpan.FromSeconds(5));
throw;
}
}
}
}