mirror of
https://github.com/claunia/romrepomgr.git
synced 2025-12-16 19:24:51 +00:00
Check if The Unarchiver is usable.
This commit is contained in:
@@ -83,7 +83,7 @@ namespace RomRepoMgr.Core.Workers
|
|||||||
outFs.Dispose();
|
outFs.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void CheckUnar(string unArPath)
|
public bool CheckUnar(string unArPath)
|
||||||
{
|
{
|
||||||
if(string.IsNullOrWhiteSpace(unArPath))
|
if(string.IsNullOrWhiteSpace(unArPath))
|
||||||
{
|
{
|
||||||
@@ -92,7 +92,7 @@ namespace RomRepoMgr.Core.Workers
|
|||||||
Message = "unar path is not set."
|
Message = "unar path is not set."
|
||||||
});
|
});
|
||||||
|
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
string unarFolder = Path.GetDirectoryName(unArPath);
|
string unarFolder = Path.GetDirectoryName(unArPath);
|
||||||
@@ -109,7 +109,7 @@ namespace RomRepoMgr.Core.Workers
|
|||||||
Message = $"Cannot find unar executable at {unarPath}."
|
Message = $"Cannot find unar executable at {unarPath}."
|
||||||
});
|
});
|
||||||
|
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!File.Exists(lsarPath))
|
if(!File.Exists(lsarPath))
|
||||||
@@ -119,7 +119,7 @@ namespace RomRepoMgr.Core.Workers
|
|||||||
Message = "Cannot find lsar executable."
|
Message = "Cannot find lsar executable."
|
||||||
});
|
});
|
||||||
|
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
string unarOut, lsarOut;
|
string unarOut, lsarOut;
|
||||||
@@ -148,7 +148,7 @@ namespace RomRepoMgr.Core.Workers
|
|||||||
Message = "Cannot run unar."
|
Message = "Cannot run unar."
|
||||||
});
|
});
|
||||||
|
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
@@ -175,7 +175,7 @@ namespace RomRepoMgr.Core.Workers
|
|||||||
Message = "Cannot run lsar."
|
Message = "Cannot run lsar."
|
||||||
});
|
});
|
||||||
|
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!unarOut.StartsWith("unar ", StringComparison.CurrentCulture))
|
if(!unarOut.StartsWith("unar ", StringComparison.CurrentCulture))
|
||||||
@@ -185,7 +185,7 @@ namespace RomRepoMgr.Core.Workers
|
|||||||
Message = "Not the correct unar executable"
|
Message = "Not the correct unar executable"
|
||||||
});
|
});
|
||||||
|
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!lsarOut.StartsWith("lsar ", StringComparison.CurrentCulture))
|
if(!lsarOut.StartsWith("lsar ", StringComparison.CurrentCulture))
|
||||||
@@ -195,7 +195,7 @@ namespace RomRepoMgr.Core.Workers
|
|||||||
Message = "Not the correct lsar executable"
|
Message = "Not the correct lsar executable"
|
||||||
});
|
});
|
||||||
|
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
var versionProcess = new Process
|
var versionProcess = new Process
|
||||||
@@ -217,6 +217,8 @@ namespace RomRepoMgr.Core.Workers
|
|||||||
{
|
{
|
||||||
Message = versionProcess.StandardOutput.ReadToEnd().TrimEnd('\n')
|
Message = versionProcess.StandardOutput.ReadToEnd().TrimEnd('\n')
|
||||||
});
|
});
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -48,6 +48,7 @@ namespace RomRepoMgr.Settings
|
|||||||
const string XDG_CONFIG_HOME_RESOLVED = ".config";
|
const string XDG_CONFIG_HOME_RESOLVED = ".config";
|
||||||
/// <summary>Current statistcs</summary>
|
/// <summary>Current statistcs</summary>
|
||||||
public static SetSettings Current;
|
public static SetSettings Current;
|
||||||
|
public static bool UnArUsable { get; set; }
|
||||||
|
|
||||||
/// <summary>Loads settings</summary>
|
/// <summary>Loads settings</summary>
|
||||||
public static void LoadSettings()
|
public static void LoadSettings()
|
||||||
|
|||||||
@@ -68,14 +68,14 @@ namespace RomRepoMgr.ViewModels
|
|||||||
FolderPath = folderPath;
|
FolderPath = folderPath;
|
||||||
_removeFilesChecked = false;
|
_removeFilesChecked = false;
|
||||||
_knownOnlyChecked = true;
|
_knownOnlyChecked = true;
|
||||||
_recurseArchivesChecked = false;
|
_recurseArchivesChecked = Settings.Settings.UnArUsable;
|
||||||
ImportResults = new ObservableCollection<ImportRomFolderItem>();
|
ImportResults = new ObservableCollection<ImportRomFolderItem>();
|
||||||
CloseCommand = ReactiveCommand.Create(ExecuteCloseCommand);
|
CloseCommand = ReactiveCommand.Create(ExecuteCloseCommand);
|
||||||
StartCommand = ReactiveCommand.Create(ExecuteStartCommand);
|
StartCommand = ReactiveCommand.Create(ExecuteStartCommand);
|
||||||
IsReady = true;
|
IsReady = true;
|
||||||
CanStart = true;
|
CanStart = true;
|
||||||
CanClose = true;
|
CanClose = true;
|
||||||
_removeFilesEnabled = true;
|
_removeFilesEnabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string PathLabel => "Path:";
|
public string PathLabel => "Path:";
|
||||||
@@ -83,6 +83,7 @@ namespace RomRepoMgr.ViewModels
|
|||||||
public string RemoveFilesLabel => "Remove files after import successful.";
|
public string RemoveFilesLabel => "Remove files after import successful.";
|
||||||
public string KnownOnlyLabel => "Only import known files.";
|
public string KnownOnlyLabel => "Only import known files.";
|
||||||
public string RecurseArchivesLabel => "Try to detect archives and import their contents.";
|
public string RecurseArchivesLabel => "Try to detect archives and import their contents.";
|
||||||
|
public bool RecurseArchivesEnabled => Settings.Settings.UnArUsable;
|
||||||
|
|
||||||
public bool RemoveFilesChecked
|
public bool RemoveFilesChecked
|
||||||
{
|
{
|
||||||
@@ -301,7 +302,6 @@ namespace RomRepoMgr.ViewModels
|
|||||||
StatusMessage = "Finished!";
|
StatusMessage = "Finished!";
|
||||||
CanClose = true;
|
CanClose = true;
|
||||||
Progress2Visible = false;
|
Progress2Visible = false;
|
||||||
IsReady = true;
|
|
||||||
|
|
||||||
Console.WriteLine($"Took {watch.Elapsed.TotalSeconds} seconds");
|
Console.WriteLine($"Took {watch.Elapsed.TotalSeconds} seconds");
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -320,7 +320,10 @@ namespace RomRepoMgr.ViewModels
|
|||||||
Settings.Settings.Current.TemporaryFolder = TemporaryPath;
|
Settings.Settings.Current.TemporaryFolder = TemporaryPath;
|
||||||
|
|
||||||
if(_unArChanged)
|
if(_unArChanged)
|
||||||
|
{
|
||||||
Settings.Settings.Current.UnArchiverPath = UnArPath;
|
Settings.Settings.Current.UnArchiverPath = UnArPath;
|
||||||
|
Settings.Settings.UnArUsable = true;
|
||||||
|
}
|
||||||
|
|
||||||
if(_databaseChanged ||
|
if(_databaseChanged ||
|
||||||
_repositoryChanged ||
|
_repositoryChanged ||
|
||||||
|
|||||||
@@ -35,12 +35,17 @@ using Microsoft.EntityFrameworkCore;
|
|||||||
using ReactiveUI;
|
using ReactiveUI;
|
||||||
using RomRepoMgr.Core.EventArgs;
|
using RomRepoMgr.Core.EventArgs;
|
||||||
using RomRepoMgr.Core.Models;
|
using RomRepoMgr.Core.Models;
|
||||||
|
using RomRepoMgr.Core.Workers;
|
||||||
using RomRepoMgr.Database;
|
using RomRepoMgr.Database;
|
||||||
|
|
||||||
namespace RomRepoMgr.ViewModels
|
namespace RomRepoMgr.ViewModels
|
||||||
{
|
{
|
||||||
public sealed class SplashWindowViewModel : ViewModelBase
|
public sealed class SplashWindowViewModel : ViewModelBase
|
||||||
{
|
{
|
||||||
|
bool _checkingUnArError;
|
||||||
|
bool _checkingUnArOk;
|
||||||
|
string _checkingUnArText;
|
||||||
|
bool _checkingUnArUnknown;
|
||||||
string _exitButtonText;
|
string _exitButtonText;
|
||||||
bool _exitVisible;
|
bool _exitVisible;
|
||||||
bool _loadingDatabaseError;
|
bool _loadingDatabaseError;
|
||||||
@@ -48,7 +53,6 @@ namespace RomRepoMgr.ViewModels
|
|||||||
string _loadingDatabaseText;
|
string _loadingDatabaseText;
|
||||||
bool _loadingDatabaseUnknown;
|
bool _loadingDatabaseUnknown;
|
||||||
bool _loadingRomSetsError;
|
bool _loadingRomSetsError;
|
||||||
|
|
||||||
bool _loadingRomSetsOk;
|
bool _loadingRomSetsOk;
|
||||||
string _loadingRomSetsText;
|
string _loadingRomSetsText;
|
||||||
bool _loadingRomSetsUnknown;
|
bool _loadingRomSetsUnknown;
|
||||||
@@ -71,6 +75,9 @@ namespace RomRepoMgr.ViewModels
|
|||||||
LoadingSettingsOk = false;
|
LoadingSettingsOk = false;
|
||||||
LoadingSettingsError = false;
|
LoadingSettingsError = false;
|
||||||
LoadingSettingsUnknown = true;
|
LoadingSettingsUnknown = true;
|
||||||
|
CheckingUnArOk = false;
|
||||||
|
CheckingUnArError = false;
|
||||||
|
CheckingUnArUnknown = true;
|
||||||
LoadingDatabaseOk = false;
|
LoadingDatabaseOk = false;
|
||||||
LoadingDatabaseError = false;
|
LoadingDatabaseError = false;
|
||||||
LoadingDatabaseUnknown = true;
|
LoadingDatabaseUnknown = true;
|
||||||
@@ -115,6 +122,30 @@ namespace RomRepoMgr.ViewModels
|
|||||||
set => this.RaiseAndSetIfChanged(ref _loadingSettingsUnknown, value);
|
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
|
public string LoadingDatabaseText
|
||||||
{
|
{
|
||||||
get => _loadingDatabaseText;
|
get => _loadingDatabaseText;
|
||||||
@@ -206,6 +237,7 @@ namespace RomRepoMgr.ViewModels
|
|||||||
{
|
{
|
||||||
LoadingText = "ROM Repository Manager";
|
LoadingText = "ROM Repository Manager";
|
||||||
LoadingSettingsText = "Loading settings...";
|
LoadingSettingsText = "Loading settings...";
|
||||||
|
CheckingUnArText = "Checking The Unarchiver...";
|
||||||
LoadingDatabaseText = "Loading database...";
|
LoadingDatabaseText = "Loading database...";
|
||||||
MigratingDatabaseText = "Migrating database...";
|
MigratingDatabaseText = "Migrating database...";
|
||||||
LoadingRomSetsText = "Loading ROM sets...";
|
LoadingRomSetsText = "Loading ROM sets...";
|
||||||
@@ -220,7 +252,7 @@ namespace RomRepoMgr.ViewModels
|
|||||||
{
|
{
|
||||||
Settings.Settings.LoadSettings();
|
Settings.Settings.LoadSettings();
|
||||||
|
|
||||||
Dispatcher.UIThread.Post(LoadDatabase);
|
Dispatcher.UIThread.Post(CheckUnar);
|
||||||
}
|
}
|
||||||
catch(Exception e)
|
catch(Exception e)
|
||||||
{
|
{
|
||||||
@@ -236,11 +268,37 @@ namespace RomRepoMgr.ViewModels
|
|||||||
ExitVisible = true;
|
ExitVisible = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LoadDatabase()
|
void CheckUnar() => Task.Run(() =>
|
||||||
{
|
{
|
||||||
LoadingSettingsUnknown = false;
|
LoadingSettingsUnknown = false;
|
||||||
LoadingSettingsOk = true;
|
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(() =>
|
Task.Run(() =>
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|||||||
@@ -43,17 +43,19 @@
|
|||||||
<StackPanel Grid.Row="0" Orientation="Horizontal" HorizontalAlignment="Stretch">
|
<StackPanel Grid.Row="0" Orientation="Horizontal" HorizontalAlignment="Stretch">
|
||||||
<TextBlock Text="{Binding PathLabel}" FontWeight="Bold" /> <TextBlock Text="{Binding FolderPath}" />
|
<TextBlock Text="{Binding PathLabel}" FontWeight="Bold" /> <TextBlock Text="{Binding FolderPath}" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
<CheckBox Grid.Row="1" IsChecked="{Binding RemoveFilesChecked}" IsEnabled="{Binding IsReady}">
|
<CheckBox Grid.Row="1" IsChecked="{Binding RemoveFilesChecked}" IsEnabled="{Binding RemoveFilesEnabled}"
|
||||||
|
IsVisible="{Binding IsReady}">
|
||||||
<CheckBox.Content>
|
<CheckBox.Content>
|
||||||
<TextBlock Text="{Binding RemoveFilesLabel}" IsEnabled="{Binding RemoveFilesEnabled}" />
|
<TextBlock Text="{Binding RemoveFilesLabel}" />
|
||||||
</CheckBox.Content>
|
</CheckBox.Content>
|
||||||
</CheckBox>
|
</CheckBox>
|
||||||
<CheckBox Grid.Row="2" IsChecked="{Binding KnownOnlyChecked}">
|
<CheckBox Grid.Row="2" IsChecked="{Binding KnownOnlyChecked}" IsVisible="{Binding IsReady}">
|
||||||
<CheckBox.Content>
|
<CheckBox.Content>
|
||||||
<TextBlock Text="{Binding KnownOnlyLabel}" />
|
<TextBlock Text="{Binding KnownOnlyLabel}" />
|
||||||
</CheckBox.Content>
|
</CheckBox.Content>
|
||||||
</CheckBox>
|
</CheckBox>
|
||||||
<CheckBox Grid.Row="3" IsChecked="{Binding RecurseArchivesChecked}" IsEnabled="False">
|
<CheckBox Grid.Row="3" IsChecked="{Binding RecurseArchivesChecked}"
|
||||||
|
IsEnabled="{Binding RecurseArchivesEnabled}" IsVisible="{Binding IsReady}">
|
||||||
<CheckBox.Content>
|
<CheckBox.Content>
|
||||||
<TextBlock Text="{Binding RecurseArchivesLabel}" />
|
<TextBlock Text="{Binding RecurseArchivesLabel}" />
|
||||||
</CheckBox.Content>
|
</CheckBox.Content>
|
||||||
@@ -82,7 +84,7 @@
|
|||||||
</DataGridTextColumn>
|
</DataGridTextColumn>
|
||||||
</DataGrid.Columns>
|
</DataGrid.Columns>
|
||||||
</DataGrid>
|
</DataGrid>
|
||||||
<StackPanel Grid.Row="8" Orientation="Horizontal" IsVisible="{Binding IsReady}" HorizontalAlignment="Right">
|
<StackPanel Grid.Row="8" Orientation="Horizontal" HorizontalAlignment="Right">
|
||||||
<Button HorizontalAlignment="Right" VerticalAlignment="Center" IsEnabled="{Binding CanClose}"
|
<Button HorizontalAlignment="Right" VerticalAlignment="Center" IsEnabled="{Binding CanClose}"
|
||||||
Command="{Binding CloseCommand}">
|
Command="{Binding CloseCommand}">
|
||||||
<TextBlock Text="{Binding CloseLabel}" />
|
<TextBlock Text="{Binding CloseLabel}" />
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
xmlns:svg="clr-namespace:Svg.Skia.Avalonia;assembly=Svg.Skia.Avalonia" mc:Ignorable="d" d:DesignWidth="450"
|
xmlns:svg="clr-namespace:Svg.Skia.Avalonia;assembly=Svg.Skia.Avalonia" mc:Ignorable="d" d:DesignWidth="450"
|
||||||
d:DesignHeight="250" x:Class="RomRepoMgr.Views.SplashWindow" Icon="/Assets/avalonia-logo.ico"
|
d:DesignHeight="250" x:Class="RomRepoMgr.Views.SplashWindow" Icon="/Assets/avalonia-logo.ico"
|
||||||
Title="ROM Repository Manager" SystemDecorations="BorderOnly" WindowStartupLocation="CenterScreen" Width="250"
|
Title="ROM Repository Manager" SystemDecorations="BorderOnly" WindowStartupLocation="CenterScreen" Width="250"
|
||||||
Height="140">
|
Height="175">
|
||||||
<Design.DataContext>
|
<Design.DataContext>
|
||||||
<vm:SplashWindowViewModel />
|
<vm:SplashWindowViewModel />
|
||||||
</Design.DataContext>
|
</Design.DataContext>
|
||||||
@@ -30,6 +30,24 @@
|
|||||||
</Image>
|
</Image>
|
||||||
<TextBlock Text="{Binding LoadingSettingsText}" VerticalAlignment="Center" />
|
<TextBlock Text="{Binding LoadingSettingsText}" VerticalAlignment="Center" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
<StackPanel HorizontalAlignment="Left" Orientation="Horizontal">
|
||||||
|
<Image MaxWidth="24" MaxHeight="24" IsVisible="{Binding CheckingUnArOk}">
|
||||||
|
<Image.Source>
|
||||||
|
<svg:SvgImage Source="/Assets/emblem-checked.svg" />
|
||||||
|
</Image.Source>
|
||||||
|
</Image>
|
||||||
|
<Image MaxWidth="24" MaxHeight="24" IsVisible="{Binding CheckingUnArError}">
|
||||||
|
<Image.Source>
|
||||||
|
<svg:SvgImage Source="/Assets/emblem-error.svg" />
|
||||||
|
</Image.Source>
|
||||||
|
</Image>
|
||||||
|
<Image MaxWidth="24" MaxHeight="24" IsVisible="{Binding CheckingUnArUnknown}">
|
||||||
|
<Image.Source>
|
||||||
|
<svg:SvgImage Source="/Assets/emblem-question.svg" />
|
||||||
|
</Image.Source>
|
||||||
|
</Image>
|
||||||
|
<TextBlock Text="{Binding CheckingUnArText}" VerticalAlignment="Center" />
|
||||||
|
</StackPanel>
|
||||||
<StackPanel HorizontalAlignment="Left" Orientation="Horizontal">
|
<StackPanel HorizontalAlignment="Left" Orientation="Horizontal">
|
||||||
<Image MaxWidth="24" MaxHeight="24" IsVisible="{Binding LoadingDatabaseOk}">
|
<Image MaxWidth="24" MaxHeight="24" IsVisible="{Binding LoadingDatabaseOk}">
|
||||||
<Image.Source>
|
<Image.Source>
|
||||||
|
|||||||
Reference in New Issue
Block a user