Nexus-Mods / Nexus-Mod-Manager

GNU General Public License v2.0
984 stars 165 forks source link

Space at end of mod file name causes NMM to create invalid links #872

Closed ghost closed 5 years ago

ghost commented 5 years ago

This is a rare situation, but I actually have run across it a couple of times. I realize this is a bit of an esoteric error and is somewhat of an end-user error, but NMM could prevent it by validating the file names.

Describe the bug If a mod archive has a space at the end of its filename before the extension, NMM will create links in the Data folder that do not point to the files in the VirtualInstall folder.

For example, an archive called "mymod .zip" with a space between the 'd' and the dot. When NMM installs the file, the folder in VirtualInstall will not have the space. Windows does not allow spaces at the end of file or folder names, and automatically removes them at creation. So mod folders will be named e.g. "..\Fallout4\Mods\VirtualInstall\mymod\Textures\"

But the links that NMM creates in the Data folder will have the space in their target path, for example "..\Fallout4\Mods\VirtualInstall\mymod \Textures\"

Since the target does not match the actual path, the links are invalid, and the game cannot find the files. The links created by NMM look like shortcuts, and right-clicking on them and viewing Properties gives a Windows error that the target path is invalid.

Environment NMM version: 0.70.8.0 Mod(s) used: https://www.loverslab.com/files/file/7003-the-auction-house-beta/

This doesn't produce an error in NMM itself, so the install logs look normal.

To Reproduce Rename any mod archive so it has a space at the end of the base name, before the period, and install the mod.

jbostrus commented 5 years ago

@EgoBallistic I think I have a functional patch ready. I don't use the multiHD mode for it to make symlinks instead of hard links so I'm not really familiar with it. Would you be interested in testing it?

ghost commented 5 years ago

@jbostrus I'd be happy to test.

jbostrus commented 5 years ago

Cool. I'm not sure where the most appropriate place would be so as to not cause issue with others thinking they should download it. Normally I'd PM someone a private link or what not but GitHub doesn't do that. For now I suppose I could just drop it here.

To be clear this is a build based on 0.70.8 with my 3 relevant open pull requests in it. Those include the Enderal mode patches, the view reset fix, and the one for this issue thread.

Link removed.

jbostrus commented 5 years ago

I guess I should explain what I expect should happen. If you download or add a new mod with leading or trailing whitespace in the archive filename it will do so as before. However when installing the mod where it actually does the extraction of the files to the virtual folder, it should create a folder without the whitespace on the name. Then when it goes and installs the mod (making the links), those links should point to the correct location as previously extracted and thus work as it does on files without whitespace.

ghost commented 5 years ago

@jbostrus the fix works as expected. I tried it with a couple of different mods with the extra space in the filename, as well as a couple of mods with normal filenames as a control, and everything installed as expected. All the mods uninstalled cleanly as well.

FWIW I don't use multiHD mode either - the problem would occur even on the same HD. It seems that if a hardlink points to an invalid file, Windows displays it as a shortcut in the file manager.

Anyway it seems you fixed the problem, so thank you very much!

jbostrus commented 5 years ago

Thanks. Glad to get confirmation that it resolved the described issue. I'm removing the download link so an unofficial version doesn't get propagated around. Hopefully DuskDweller will pop on and merge/build a new version with my fixes soon.

jbostrus commented 5 years ago

This can be closed now as the 0.79.0 release has the fix included.