allow for no custom charmap to be present

This commit is contained in:
Yako 2025-11-11 11:33:15 +01:00
parent 78194677c2
commit 474f04869c

View File

@ -179,45 +179,25 @@ namespace DSPRE.CharMaps
public static bool IsCustomMapOutdated()
{
// Check if custom charmap file exists
if (!File.Exists(customCharmapFilePath))
if (File.Exists(customCharmapFilePath))
{
AppLogger.Warn($"No custom charmap found at: {customCharmapFilePath}");
// Both files exist, compare versions
try
{
// Ensure directory exists
if (!Directory.Exists(Program.DspreDataPath))
{
Directory.CreateDirectory(Program.DspreDataPath);
}
var defaultVersion = GetCharMapVersion(charmapFilePath);
var customVersion = GetCharMapVersion(customCharmapFilePath);
// Copy default charmap to custom path
File.Copy(charmapFilePath, customCharmapFilePath, false);
AppLogger.Info($"Created custom charmap from default at: {customCharmapFilePath}");
// Since we just created it, it's not outdated
return false;
return customVersion < defaultVersion;
}
catch (Exception ex)
{
AppLogger.Error($"Failed to create custom charmap: {ex.Message}");
return false; // Don't treat as outdated if creation failed
AppLogger.Error($"Error comparing charmap versions: {ex.Message}");
return false; // Don't treat as outdated if comparison failed
}
}
// Both files exist, compare versions
try
{
var defaultVersion = GetCharMapVersion(charmapFilePath);
var customVersion = GetCharMapVersion(customCharmapFilePath);
return false; // Custom charmap does not exist, so not outdated
return customVersion < defaultVersion;
}
catch (Exception ex)
{
AppLogger.Error($"Error comparing charmap versions: {ex.Message}");
return false; // Don't treat as outdated if comparison failed
}
}
/// <summary>