From 45ea04ae540aca081d07ce5a9abdef72a25e3301 Mon Sep 17 00:00:00 2001 From: Lauriethefish Date: Sat, 23 Dec 2023 10:47:03 +0000 Subject: [PATCH] Fix URL encoding causing incorrect file name --- QuestPatcher/ViewModels/LoadedViewModel.cs | 23 +++++++++++----------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/QuestPatcher/ViewModels/LoadedViewModel.cs b/QuestPatcher/ViewModels/LoadedViewModel.cs index cb8a868..489eb9d 100644 --- a/QuestPatcher/ViewModels/LoadedViewModel.cs +++ b/QuestPatcher/ViewModels/LoadedViewModel.cs @@ -83,6 +83,14 @@ public LoadedViewModel(PatchingViewModel patchingView, ManageModsViewModel manag }; } + private FileImportInfo GetImportInfoForUri(Uri fileUri) + { + return new FileImportInfo(fileUri.LocalPath) // No need to escape: using local path + { + PreferredCopyType = OtherItemsView.SelectedFileCopy, + }; + } + public async void OnDragAndDrop(object? sender, DragEventArgs args) { Log.Debug("Handling drag and drop on LoadedViewModel"); @@ -103,7 +111,7 @@ public async void OnDragAndDrop(object? sender, DragEventArgs args) if (scheme == "file") { - filesToImport.Add(uri.AbsolutePath); + await _browseManager.AttemptImportFiles(new FileImportInfo[] { GetImportInfoForUri(uri) }); } else if (uri.Scheme == "http" || uri.Scheme == "https") { @@ -116,19 +124,10 @@ public async void OnDragAndDrop(object? sender, DragEventArgs args) var files = args.Data.GetFiles(); if (files != null) { - filesToImport.AddRange(files.Select(file => file.Path.LocalPath)); + Log.Debug("Files found in drag and drop. Processing . . ."); + await _browseManager.AttemptImportFiles(files.Select(file => GetImportInfoForUri(file.Path)).ToList()); } } - - if (filesToImport.Count != 0) - { - Log.Debug("Files found in drag and drop. Processing . . ."); - await _browseManager.AttemptImportFiles(filesToImport.Select(file => new FileImportInfo(file) - { - PreferredCopyType = OtherItemsView.SelectedFileCopy - }).ToList()); - } - } catch (Exception ex) {