When the following URL https://pcmars.com/download/pcmars-update-3-0-6-2/?wpdmdl=542&refresh=658352576092e1703105111&ind=543&filename=PcMars-Update-3.0.zip
is sent to TWebUpdate.URLtoFile it returns the empty string instead of PcMars-Update-3.0.zip
The website is a WordPress website with the WordPress Download Manager plugin installed which is where the URL is coming from.
This then causes the update to fail as it tries to rename a file that does not exist and a dialog with "Failed to download updates" is displayed.
Is there a way for TWebUpdate.URLtoFile to get the filename from that URL?
The function URLToFile() cannot guess that you pass the filename via a query parameter.
It parses something like http://domainname/folderstructure/filename
You would need to custom parse this URL and you can do this via the event WebUpdate.OnFileNameFromURL()
It looks like OnFileNameFromURL just will replace one specific URL with one specific filename. I could be wrong but if this is how OnFileNameFromURL works then this will not work for us as the URL will change when a new update is released. I am looking for a solution that is flexible such as a way to call a method that can parse that URL (where the filename is a query parameter) and return a filename that TWebUpdate can use. I can write the method to parse the URL. You are right in that URLToFile cannot figure out the particular query parameter that contains the filename.
I'm sorry but I do not really understand the point you try to make.
The exact purpose of OnFileNameFromURL is to custom parse any URL and retrieve a FileName from it.
So, if you implement your own parsing to look into the query param for the FileName, this should do what you need.