Philipp Heenemann d3767a0344 Add global using directives and free space pre-check
Global System and System.IO usages have been replaced with global usings in GlobalUsings.cs for improved code readability. Alongside, a FreeSpacePreCheck has been added in FreeSpacePreCheck.cs to ensure enough drive space is available before installation. This check was initially taking place in InitializationTask.cs which has been removed for better separation of concerns. The PreCheckViewModel visibility is now dependent on the success status of PreChecks, enhancing user experience.
2023-07-12 08:32:57 +02:00

60 lines
2.1 KiB
C#

using SPTInstaller.Aki.Helper;
using SPTInstaller.Interfaces;
using SPTInstaller.Models;
using System.Threading.Tasks;
namespace SPTInstaller.Installer_Tasks
{
public class InitializationTask : InstallerTaskBase
{
private InternalData _data;
public InitializationTask(InternalData data) : base("Startup")
{
_data = data;
}
public override async Task<IResult> TaskOperation()
{
SetStatus("Initializing", $"Target Install Path: {FileHelper.GetRedactedPath(_data.TargetInstallPath)}");
_data.OriginalGamePath = PreCheckHelper.DetectOriginalGamePath();
if (_data.OriginalGamePath == null)
{
return Result.FromError("EFT IS NOT INSTALLED!");
}
SetStatus(null, $"Installed EFT Game Path: {FileHelper.GetRedactedPath(_data.OriginalGamePath)}");
var result = PreCheckHelper.DetectOriginalGameVersion(_data.OriginalGamePath);
if (!result.Succeeded)
{
return result;
}
_data.OriginalGameVersion = result.Message;
SetStatus(null, $"Installed EFT Game Version: {_data.OriginalGameVersion}");
if (_data.OriginalGamePath == null)
{
return Result.FromError("Unable to find original EFT directory, please make sure EFT is installed. Please also run EFT once");
}
if (_data.OriginalGamePath == _data.TargetInstallPath)
{
return Result.FromError("Installer is located in EFT's original directory. Please move the installer to a seperate folder as per the guide");
}
if (File.Exists(Path.Join(_data.TargetInstallPath, "EscapeFromTarkov.exe")))
{
return Result.FromError("Installer is located in a folder that has existing game files. Please make sure the installer is in a fresh folder as per the guide");
}
return Result.FromSuccess($"Current Game Version: {_data.OriginalGameVersion}");
}
}
}