add more resilience to MCDF export and loading

This commit is contained in:
rootdarkarchon
2023-12-07 09:43:43 +01:00
parent bd32a55ce5
commit 8a197e6387
3 changed files with 52 additions and 31 deletions

View File

@@ -54,6 +54,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
private Task<List<FileCacheEntity>>? _validationTask;
private CancellationTokenSource? _validationCts;
private (int, int, FileCacheEntity) _currentProgress;
private Task? _exportTask;
public SettingsUi(ILogger<SettingsUi> logger,
UiSharedService uiShared, MareConfigService configService,
@@ -439,17 +440,11 @@ public class SettingsUi : WindowMediatorSubscriberBase
_configService.Current.ExportFolder = Path.GetDirectoryName(path) ?? string.Empty;
_configService.Save();
_ = Task.Run(() =>
_exportTask = Task.Run(() =>
{
try
{
_mareCharaFileManager.SaveMareCharaFile(LastCreatedCharacterData, _exportDescription, path);
_exportDescription = string.Empty;
}
catch (Exception ex)
{
_logger.LogCritical(ex, "Error saving data");
}
var desc = _exportDescription;
_exportDescription = string.Empty;
_mareCharaFileManager.SaveMareCharaFile(LastCreatedCharacterData, desc, path);
});
}, Directory.Exists(_configService.Current.ExportFolder) ? _configService.Current.ExportFolder : null);
}
@@ -461,6 +456,11 @@ public class SettingsUi : WindowMediatorSubscriberBase
UiSharedService.ColorTextWrapped("Export in progress", ImGuiColors.DalamudYellow);
}
if (_exportTask?.IsFaulted ?? false)
{
UiSharedService.ColorTextWrapped("Export failed, check /xllog for more details.", ImGuiColors.DalamudRed);
}
ImGui.Unindent();
}
bool openInGpose = _configService.Current.OpenGposeImportOnGposeStart;