private async Task <SaveResult> ReloadInternalAsync(IFileState fileState, IFileSystem destinationFileSystem, UPath savePath, SaveInfo saveInfo) { // 1. Reload current state var temporaryStreamProvider = fileState.StreamManager.CreateTemporaryStreamProvider(); var internalDialogManager = new InternalDialogManager(saveInfo.DialogManager, fileState.DialogOptions); var loadContext = new LoadContext(temporaryStreamProvider, saveInfo.Progress, internalDialogManager); var reloadResult = await TryLoadStateAsync(fileState.PluginState, destinationFileSystem, savePath.ToAbsolute(), loadContext); if (!reloadResult.IsSuccessful) { return(new SaveResult(reloadResult.Exception)); } // 2. Set new file input, if state was loaded from a physical medium if (!fileState.HasParent) { fileState.SetNewFileInput(destinationFileSystem, savePath); } // 3. Reload all child states foreach (var archiveChild in fileState.ArchiveChildren) { var destination = archiveChild.FileSystem.Clone(archiveChild.StreamManager); var reloadChildResult = await ReloadInternalAsync(archiveChild, destination, archiveChild.FilePath, saveInfo); if (!reloadChildResult.IsSuccessful) { return(reloadChildResult); } } return(SaveResult.SuccessfulResult); }
private async Task <SaveResult> ReloadInternalAsync(IStateInfo stateInfo, IFileSystem destinationFileSystem, UPath savePath, IProgressContext progress) { // 1. Reload current state var temporaryStreamProvider = stateInfo.StreamManager.CreateTemporaryStreamProvider(); savePath = stateInfo.HasParent ? savePath : savePath.GetName(); var internalDialogManager = new InternalDialogManager(_dialogManager, stateInfo.DialogOptions); var loadContext = new LoadContext(temporaryStreamProvider, progress, internalDialogManager); var reloadResult = await TryLoadStateAsync(stateInfo.PluginState, destinationFileSystem, savePath, loadContext); if (!reloadResult.IsSuccessful) { return(new SaveResult(reloadResult.Exception)); } // 2. Set new file input, if state was loaded from a physical medium if (!stateInfo.HasParent) { stateInfo.SetNewFileInput(destinationFileSystem, savePath); } // 3. Reload all child states foreach (var archiveChild in stateInfo.ArchiveChildren) { var destination = CreateDestinationFileSystem(archiveChild, archiveChild.FilePath); var reloadChildResult = await ReloadInternalAsync(archiveChild, destination, archiveChild.FilePath, progress); if (!reloadChildResult.IsSuccessful) { return(reloadChildResult); } } return(SaveResult.SuccessfulResult); }