Check if The Unarchiver is usable.

This commit is contained in:
2020-08-23 21:21:55 +01:00
parent b698e75739
commit 8f289e3939
7 changed files with 109 additions and 25 deletions

View File

@@ -68,21 +68,22 @@ namespace RomRepoMgr.ViewModels
FolderPath = folderPath;
_removeFilesChecked = false;
_knownOnlyChecked = true;
_recurseArchivesChecked = false;
_recurseArchivesChecked = Settings.Settings.UnArUsable;
ImportResults = new ObservableCollection<ImportRomFolderItem>();
CloseCommand = ReactiveCommand.Create(ExecuteCloseCommand);
StartCommand = ReactiveCommand.Create(ExecuteStartCommand);
IsReady = true;
CanStart = true;
CanClose = true;
_removeFilesEnabled = true;
_removeFilesEnabled = false;
}
public string PathLabel => "Path:";
public string FolderPath { get; }
public string RemoveFilesLabel => "Remove files after import successful.";
public string KnownOnlyLabel => "Only import known files.";
public string RecurseArchivesLabel => "Try to detect archives and import their contents.";
public string PathLabel => "Path:";
public string FolderPath { get; }
public string RemoveFilesLabel => "Remove files after import successful.";
public string KnownOnlyLabel => "Only import known files.";
public string RecurseArchivesLabel => "Try to detect archives and import their contents.";
public bool RecurseArchivesEnabled => Settings.Settings.UnArUsable;
public bool RemoveFilesChecked
{
@@ -301,7 +302,6 @@ namespace RomRepoMgr.ViewModels
StatusMessage = "Finished!";
CanClose = true;
Progress2Visible = false;
IsReady = true;
Console.WriteLine($"Took {watch.Elapsed.TotalSeconds} seconds");
});

View File

@@ -320,7 +320,10 @@ namespace RomRepoMgr.ViewModels
Settings.Settings.Current.TemporaryFolder = TemporaryPath;
if(_unArChanged)
{
Settings.Settings.Current.UnArchiverPath = UnArPath;
Settings.Settings.UnArUsable = true;
}
if(_databaseChanged ||
_repositoryChanged ||

View File

@@ -35,12 +35,17 @@ using Microsoft.EntityFrameworkCore;
using ReactiveUI;
using RomRepoMgr.Core.EventArgs;
using RomRepoMgr.Core.Models;
using RomRepoMgr.Core.Workers;
using RomRepoMgr.Database;
namespace RomRepoMgr.ViewModels
{
public sealed class SplashWindowViewModel : ViewModelBase
{
bool _checkingUnArError;
bool _checkingUnArOk;
string _checkingUnArText;
bool _checkingUnArUnknown;
string _exitButtonText;
bool _exitVisible;
bool _loadingDatabaseError;
@@ -48,7 +53,6 @@ namespace RomRepoMgr.ViewModels
string _loadingDatabaseText;
bool _loadingDatabaseUnknown;
bool _loadingRomSetsError;
bool _loadingRomSetsOk;
string _loadingRomSetsText;
bool _loadingRomSetsUnknown;
@@ -71,6 +75,9 @@ namespace RomRepoMgr.ViewModels
LoadingSettingsOk = false;
LoadingSettingsError = false;
LoadingSettingsUnknown = true;
CheckingUnArOk = false;
CheckingUnArError = false;
CheckingUnArUnknown = true;
LoadingDatabaseOk = false;
LoadingDatabaseError = false;
LoadingDatabaseUnknown = true;
@@ -115,6 +122,30 @@ namespace RomRepoMgr.ViewModels
set => this.RaiseAndSetIfChanged(ref _loadingSettingsUnknown, value);
}
public string CheckingUnArText
{
get => _checkingUnArText;
set => this.RaiseAndSetIfChanged(ref _checkingUnArText, value);
}
public bool CheckingUnArOk
{
get => _checkingUnArOk;
set => this.RaiseAndSetIfChanged(ref _checkingUnArOk, value);
}
public bool CheckingUnArError
{
get => _checkingUnArError;
set => this.RaiseAndSetIfChanged(ref _checkingUnArError, value);
}
public bool CheckingUnArUnknown
{
get => _checkingUnArUnknown;
set => this.RaiseAndSetIfChanged(ref _checkingUnArUnknown, value);
}
public string LoadingDatabaseText
{
get => _loadingDatabaseText;
@@ -206,6 +237,7 @@ namespace RomRepoMgr.ViewModels
{
LoadingText = "ROM Repository Manager";
LoadingSettingsText = "Loading settings...";
CheckingUnArText = "Checking The Unarchiver...";
LoadingDatabaseText = "Loading database...";
MigratingDatabaseText = "Migrating database...";
LoadingRomSetsText = "Loading ROM sets...";
@@ -220,7 +252,7 @@ namespace RomRepoMgr.ViewModels
{
Settings.Settings.LoadSettings();
Dispatcher.UIThread.Post(LoadDatabase);
Dispatcher.UIThread.Post(CheckUnar);
}
catch(Exception e)
{
@@ -236,11 +268,37 @@ namespace RomRepoMgr.ViewModels
ExitVisible = true;
}
void LoadDatabase()
void CheckUnar() => Task.Run(() =>
{
LoadingSettingsUnknown = false;
LoadingSettingsOk = true;
try
{
var worker = new Compression();
Settings.Settings.UnArUsable = worker.CheckUnar(Settings.Settings.Current.UnArchiverPath);
Dispatcher.UIThread.Post(LoadDatabase);
}
catch(Exception e)
{
// TODO: Log error
Dispatcher.UIThread.Post(FailedCheckUnar);
}
});
void FailedCheckUnar()
{
CheckingUnArUnknown = false;
CheckingUnArError = true;
ExitVisible = true;
}
void LoadDatabase()
{
CheckingUnArUnknown = false;
CheckingUnArOk = true;
Task.Run(() =>
{
try