Metalink ignores -O
I have been using Wget2 on Gentoo to download distfiles and ran into a very non-obvious issue with metalinks.
$ wget2 -v --progress=none -t 3 -T 60 -O /tmp/pyside-setup-everywhere-src-6.8.0.tar.xz.__download__ https://download.qt.io/official_releases/QtForPython/pyside6/PySide6-6.8.0.2-src/pyside-setup-everywhere-src-6.8.0.tar.xz
[0] Downloading 'https://download.qt.io/official_releases/QtForPython/pyside6/PySide6-6.8.0.2-src/pyside-setup-everywhere-src-6.8.0.tar.xz' ...
HTTP response 302 Found [https://download.qt.io/official_releases/QtForPython/pyside6/PySide6-6.8.0.2-src/pyside-setup-everywhere-src-6.8.0.tar.xz]
Adding URL: https://download.qt.io/official_releases/QtForPython/pyside6/PySide6-6.8.0.2-src/pyside-setup-everywhere-src-6.8.0.tar.xz.meta4
[0] Downloading 'https://download.qt.io/official_releases/QtForPython/pyside6/PySide6-6.8.0.2-src/pyside-setup-everywhere-src-6.8.0.tar.xz.meta4' ...
HTTP response 200 OK [https://download.qt.io/official_releases/QtForPython/pyside6/PySide6-6.8.0.2-src/pyside-setup-everywhere-src-6.8.0.tar.xz.meta4]
If you run the above you will see that it downloads into your current directory and not as one would expect /tmp/pyside-setup-everywhere-src-6.8.0.tar.xz.__download__. This causes Portage to enter an infinite loop where it keeps trying over and over again to download the same file and fails because it never ends up in the correct $DISTDIR
The metalink (which I will attach) in question has a single <file> element.
With the original Wget this was never an issue because metalink is often disabled and even when compiled in it requires specific flags to use.
Enabling metalink by default is good in my opinion, but it should be done properly. In my opinion if there is a single <file> element then wget2 should honour -O and save the file as the user desires, if there is more than one file then it should be an error to use metalink unless some specific flag is used.