Merge pull request 'fix/exclude-live-logs' (#32) from waffle.lord/SPT-AKI-Installer:fix/exclude-live-logs into master
Reviewed-on: CWX/SPT-AKI-Installer#32
This commit is contained in:
commit
7f856964c0
@ -8,12 +8,28 @@ namespace SPTInstaller.Helpers;
|
|||||||
|
|
||||||
public static class FileHelper
|
public static class FileHelper
|
||||||
{
|
{
|
||||||
private static Result IterateDirectories(DirectoryInfo sourceDir, DirectoryInfo targetDir)
|
private static Result IterateDirectories(DirectoryInfo sourceDir, DirectoryInfo targetDir, string[] exclusions)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
foreach (var dir in sourceDir.GetDirectories("*", SearchOption.AllDirectories))
|
foreach (var dir in sourceDir.GetDirectories("*", SearchOption.AllDirectories))
|
||||||
{
|
{
|
||||||
|
var exclude = false;
|
||||||
|
|
||||||
|
foreach (var exclusion in exclusions)
|
||||||
|
{
|
||||||
|
var currentDirRelativePath = dir.FullName.Replace(sourceDir.FullName, "");
|
||||||
|
|
||||||
|
if (currentDirRelativePath.StartsWith(exclusion) || currentDirRelativePath == exclusion)
|
||||||
|
{
|
||||||
|
exclude = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (exclude)
|
||||||
|
continue;
|
||||||
|
|
||||||
Directory.CreateDirectory(dir.FullName.Replace(sourceDir.FullName, targetDir.FullName));
|
Directory.CreateDirectory(dir.FullName.Replace(sourceDir.FullName, targetDir.FullName));
|
||||||
}
|
}
|
||||||
return Result.FromSuccess();
|
return Result.FromSuccess();
|
||||||
@ -25,7 +41,7 @@ public static class FileHelper
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Result IterateFiles(DirectoryInfo sourceDir, DirectoryInfo targetDir, Action<string, int> updateCallback = null)
|
private static Result IterateFiles(DirectoryInfo sourceDir, DirectoryInfo targetDir, string[] exclusions, Action<string, int> updateCallback = null)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -34,8 +50,24 @@ public static class FileHelper
|
|||||||
|
|
||||||
foreach (var file in sourceDir.GetFiles("*.*", SearchOption.AllDirectories))
|
foreach (var file in sourceDir.GetFiles("*.*", SearchOption.AllDirectories))
|
||||||
{
|
{
|
||||||
|
var exclude = false;
|
||||||
|
|
||||||
updateCallback?.Invoke(file.Name, (int)Math.Floor(((double)processedFiles / totalFiles) * 100));
|
updateCallback?.Invoke(file.Name, (int)Math.Floor(((double)processedFiles / totalFiles) * 100));
|
||||||
|
|
||||||
|
foreach (var exclusion in exclusions)
|
||||||
|
{
|
||||||
|
var currentFileRelativePath = file.FullName.Replace(sourceDir.FullName, "");
|
||||||
|
|
||||||
|
if (currentFileRelativePath.StartsWith(exclusion) || currentFileRelativePath == exclusion)
|
||||||
|
{
|
||||||
|
exclude = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (exclude)
|
||||||
|
continue;
|
||||||
|
|
||||||
File.Copy(file.FullName, file.FullName.Replace(sourceDir.FullName, targetDir.FullName), true);
|
File.Copy(file.FullName, file.FullName.Replace(sourceDir.FullName, targetDir.FullName), true);
|
||||||
processedFiles++;
|
processedFiles++;
|
||||||
}
|
}
|
||||||
@ -62,18 +94,18 @@ public static class FileHelper
|
|||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Result CopyDirectoryWithProgress(DirectoryInfo sourceDir, DirectoryInfo targetDir, IProgress<double> progress = null) =>
|
public static Result CopyDirectoryWithProgress(DirectoryInfo sourceDir, DirectoryInfo targetDir, IProgress<double> progress = null, string[] exclusions = null) =>
|
||||||
CopyDirectoryWithProgress(sourceDir, targetDir, (msg, prog) => progress?.Report(prog));
|
CopyDirectoryWithProgress(sourceDir, targetDir, (msg, prog) => progress?.Report(prog), exclusions);
|
||||||
|
|
||||||
public static Result CopyDirectoryWithProgress(DirectoryInfo sourceDir, DirectoryInfo targetDir, Action<string, int> updateCallback = null)
|
public static Result CopyDirectoryWithProgress(DirectoryInfo sourceDir, DirectoryInfo targetDir, Action<string, int> updateCallback = null, string[] exclusions = null)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var iterateDirectoriesResult = IterateDirectories(sourceDir, targetDir);
|
var iterateDirectoriesResult = IterateDirectories(sourceDir, targetDir, exclusions ??= new string[0]);
|
||||||
|
|
||||||
if(!iterateDirectoriesResult.Succeeded) return iterateDirectoriesResult;
|
if(!iterateDirectoriesResult.Succeeded) return iterateDirectoriesResult;
|
||||||
|
|
||||||
var iterateFilesResult = IterateFiles(sourceDir, targetDir, updateCallback);
|
var iterateFilesResult = IterateFiles(sourceDir, targetDir, exclusions ??= new string[0], updateCallback);
|
||||||
|
|
||||||
if (!iterateFilesResult.Succeeded) return iterateDirectoriesResult;
|
if (!iterateFilesResult.Succeeded) return iterateDirectoriesResult;
|
||||||
|
|
||||||
|
@ -21,6 +21,9 @@ public class CopyClientTask : InstallerTaskBase
|
|||||||
var originalGameDirInfo = new DirectoryInfo(_data.OriginalGamePath);
|
var originalGameDirInfo = new DirectoryInfo(_data.OriginalGamePath);
|
||||||
var targetInstallDirInfo = new DirectoryInfo(_data.TargetInstallPath);
|
var targetInstallDirInfo = new DirectoryInfo(_data.TargetInstallPath);
|
||||||
|
|
||||||
return FileHelper.CopyDirectoryWithProgress(originalGameDirInfo, targetInstallDirInfo, (message, progress) => { SetStatus(null, message, progress, null, true); });
|
// relative path for exclusions
|
||||||
|
var exclusions = new[] { "\\Logs" };
|
||||||
|
|
||||||
|
return FileHelper.CopyDirectoryWithProgress(originalGameDirInfo, targetInstallDirInfo, (message, progress) => { SetStatus(null, message, progress, null, true); }, exclusions);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -34,11 +34,6 @@ public class InitializationTask : InstallerTaskBase
|
|||||||
return Result.FromError("Unable to find original EFT directory, please make sure EFT is installed. Please also run EFT once");
|
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")))
|
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.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");
|
||||||
|
@ -9,8 +9,8 @@
|
|||||||
<PackageIcon>icon.ico</PackageIcon>
|
<PackageIcon>icon.ico</PackageIcon>
|
||||||
<ApplicationIcon>Assets\icon.ico</ApplicationIcon>
|
<ApplicationIcon>Assets\icon.ico</ApplicationIcon>
|
||||||
<Configurations>Debug;Release;TEST</Configurations>
|
<Configurations>Debug;Release;TEST</Configurations>
|
||||||
<AssemblyVersion>2.12</AssemblyVersion>
|
<AssemblyVersion>2.13</AssemblyVersion>
|
||||||
<FileVersion>2.12</FileVersion>
|
<FileVersion>2.13</FileVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -54,7 +54,7 @@ public class MessageViewModel : ViewModelBase
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
public MessageViewModel(IScreen Host, IResult result, bool showCloseButton = true) : base(Host)
|
public MessageViewModel(IScreen Host, IResult result, bool showCloseButton = true, bool noLog = false) : base(Host)
|
||||||
{
|
{
|
||||||
ShowCloseButton = showCloseButton;
|
ShowCloseButton = showCloseButton;
|
||||||
Message = result.Message;
|
Message = result.Message;
|
||||||
@ -75,6 +75,8 @@ public class MessageViewModel : ViewModelBase
|
|||||||
}
|
}
|
||||||
|
|
||||||
HasErrors = true;
|
HasErrors = true;
|
||||||
Log.Error(Message);
|
|
||||||
|
if (!noLog)
|
||||||
|
Log.Error(Message);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -2,6 +2,7 @@
|
|||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
|
using Avalonia.Controls;
|
||||||
using Avalonia.Threading;
|
using Avalonia.Threading;
|
||||||
using DialogHostAvalonia;
|
using DialogHostAvalonia;
|
||||||
using ReactiveUI;
|
using ReactiveUI;
|
||||||
@ -78,6 +79,7 @@ public class PreChecksViewModel : ViewModelBase
|
|||||||
if (data.OriginalGamePath == null)
|
if (data.OriginalGamePath == null)
|
||||||
{
|
{
|
||||||
NavigateTo(new MessageViewModel(HostScreen, Result.FromError("Could not find EFT install.\n\nDo you own and have the game installed?")));
|
NavigateTo(new MessageViewModel(HostScreen, Result.FromError("Could not find EFT install.\n\nDo you own and have the game installed?")));
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -86,6 +88,26 @@ public class PreChecksViewModel : ViewModelBase
|
|||||||
|
|
||||||
Log.Information($"Install Path: {FileHelper.GetRedactedPath(InstallPath)}");
|
Log.Information($"Install Path: {FileHelper.GetRedactedPath(InstallPath)}");
|
||||||
|
|
||||||
|
if (data.OriginalGamePath == data.TargetInstallPath)
|
||||||
|
{
|
||||||
|
Log.CloseAndFlush();
|
||||||
|
|
||||||
|
var logFiles = Directory.GetFiles(InstallPath, "spt-aki-installer_*.log");
|
||||||
|
|
||||||
|
// remove log file from original game path if they exist
|
||||||
|
foreach (var file in logFiles)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
File.Delete(file);
|
||||||
|
}
|
||||||
|
catch { }
|
||||||
|
}
|
||||||
|
|
||||||
|
NavigateTo(new MessageViewModel(HostScreen, Result.FromError("Installer is located in EFT's original directory. Please move the installer to a seperate folder as per the guide"), noLog: true));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Task.Run(async () =>
|
Task.Run(async () =>
|
||||||
{
|
{
|
||||||
if (FileHelper.CheckPathForProblemLocations(InstallPath))
|
if (FileHelper.CheckPathForProblemLocations(InstallPath))
|
||||||
|
@ -38,7 +38,7 @@
|
|||||||
Padding="20 10"
|
Padding="20 10"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<cc:CacheInfo Grid.Row="4" Padding="10" Margin="10 0 0 0"
|
<cc:CacheInfo Grid.Row="4" Grid.ColumnSpan="3" Padding="10" Margin="10 0 0 0"
|
||||||
VerticalAlignment="Bottom"
|
VerticalAlignment="Bottom"
|
||||||
InfoText="{Binding CacheInfoText}" State="{Binding CacheCheckState}"
|
InfoText="{Binding CacheInfoText}" State="{Binding CacheCheckState}"
|
||||||
/>
|
/>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user