Skip to content

Commit

Permalink
Fix URL encoding causing incorrect file name
Browse files Browse the repository at this point in the history
  • Loading branch information
Lauriethefish committed Dec 23, 2023
1 parent 483eda2 commit 45ea04a
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions QuestPatcher/ViewModels/LoadedViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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")
{
Expand All @@ -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)
{
Expand Down

0 comments on commit 45ea04a

Please sign in to comment.