Added detection of existing files in installpath with confirmation dialog ( avoided by overwrite installation tickbox ) (#2369)

update changelog

added logic to skip past known last install location when preopulating modlist paths

code style

Co-authored-by: Timothy Baldridge <tbaldridge@gmail.com>
This commit is contained in:
JanuarySnow 2023-07-16 22:26:45 +01:00 committed by GitHub
parent 005466e53b
commit a8c5f0e89c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 1 deletions

View File

@ -3,6 +3,7 @@
#### Version TBD
* Fixed issues related to high RAM usage
* The resumable downloads now reserve drive space to write to in advance instead of being managed in system RAM
* Added safety to install path selection, to ensure that no files are deleted that are not intended to be.
* Fixed allowing back button during install which can result in multiple install processes
* fixed search filter not applying when pressing back button and reaccessing gallery
* Added more robust checking for protected location paths and subfolders for the launcher exe and install and download paths

View File

@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
@ -34,6 +34,7 @@ using Wabbajack.RateLimiter;
using Wabbajack.Paths.IO;
using Wabbajack.Services.OSIntegrated;
using Wabbajack.Util;
using System.Windows.Forms;
namespace Wabbajack;
@ -132,6 +133,8 @@ public class InstallerVM : BackNavigatingVM, IBackNavigatingVM, ICpuStatusVM
public bool ShowNSFWSlides { get; set; }
public LogStream LoggerProvider { get; }
private AbsolutePath LastInstallPath { get; set; }
// Command properties
@ -300,6 +303,24 @@ public class InstallerVM : BackNavigatingVM, IBackNavigatingVM, ICpuStatusVM
{
yield return ErrorResponse.Fail("Installing in this folder may overwrite Wabbajack");
}
if (installPath.ToString().Length != 0 && installPath != LastInstallPath &&
!Installer.AutomaticallyOverwrite &&
Directory.EnumerateFileSystemEntries(installPath.ToString()).Any())
{
string message = "There are existing files in the chosen install path, they will be deleted or overwritten (if updating existing modlist), continue?";
string title = "Files found in install folder";
MessageBoxButtons buttons = MessageBoxButtons.YesNo;
DialogResult result = MessageBox.Show(message, title, buttons);
if (result == DialogResult.Yes)
{
// everythings fine
}
else
{
Installer.Location.TargetPath = "".ToAbsolutePath();
}
if (KnownFolders.IsInSpecialFolder(installPath) || KnownFolders.IsInSpecialFolder(downloadPath))
{
yield return ErrorResponse.Fail("Can't install a modlist into Windows protected locations - such as Downloads, Documents etc");
@ -370,6 +391,7 @@ public class InstallerVM : BackNavigatingVM, IBackNavigatingVM, ICpuStatusVM
if (prevSettings.ModListLocation == path)
{
ModListLocation.TargetPath = prevSettings.ModListLocation;
LastInstallPath = prevSettings.InstallLocation;
Installer.Location.TargetPath = prevSettings.InstallLocation;
Installer.DownloadLocation.TargetPath = prevSettings.DownloadLoadction;
ModlistMetadata = metadata ?? prevSettings.Metadata;