Skip to content

Commit 45ea04a

Browse files
committed
Fix URL encoding causing incorrect file name
1 parent 483eda2 commit 45ea04a

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

QuestPatcher/ViewModels/LoadedViewModel.cs

+11-12
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,14 @@ public LoadedViewModel(PatchingViewModel patchingView, ManageModsViewModel manag
8383
};
8484
}
8585

86+
private FileImportInfo GetImportInfoForUri(Uri fileUri)
87+
{
88+
return new FileImportInfo(fileUri.LocalPath) // No need to escape: using local path
89+
{
90+
PreferredCopyType = OtherItemsView.SelectedFileCopy,
91+
};
92+
}
93+
8694
public async void OnDragAndDrop(object? sender, DragEventArgs args)
8795
{
8896
Log.Debug("Handling drag and drop on LoadedViewModel");
@@ -103,7 +111,7 @@ public async void OnDragAndDrop(object? sender, DragEventArgs args)
103111

104112
if (scheme == "file")
105113
{
106-
filesToImport.Add(uri.AbsolutePath);
114+
await _browseManager.AttemptImportFiles(new FileImportInfo[] { GetImportInfoForUri(uri) });
107115
}
108116
else if (uri.Scheme == "http" || uri.Scheme == "https")
109117
{
@@ -116,19 +124,10 @@ public async void OnDragAndDrop(object? sender, DragEventArgs args)
116124
var files = args.Data.GetFiles();
117125
if (files != null)
118126
{
119-
filesToImport.AddRange(files.Select(file => file.Path.LocalPath));
127+
Log.Debug("Files found in drag and drop. Processing . . .");
128+
await _browseManager.AttemptImportFiles(files.Select(file => GetImportInfoForUri(file.Path)).ToList());
120129
}
121130
}
122-
123-
if (filesToImport.Count != 0)
124-
{
125-
Log.Debug("Files found in drag and drop. Processing . . .");
126-
await _browseManager.AttemptImportFiles(filesToImport.Select(file => new FileImportInfo(file)
127-
{
128-
PreferredCopyType = OtherItemsView.SelectedFileCopy
129-
}).ToList());
130-
}
131-
132131
}
133132
catch (Exception ex)
134133
{

0 commit comments

Comments
 (0)