Installer cannot return multiple directory paths with same destination
krateng opened this issue · comments
This happens on multiple mods, but just as an example, I have the fomod Bijin Wives. The ModuleConfig.xml
file is properly parsed to install multiple paths for one option:
mod = pyfomod.parse((None,"./ModuleConfig.xml"))
page1 = mod.pages[0]
group1 = page1[0]
option1 = group1[0]
print(option1.name)
# All IN ONE
print(option1.files)
# <pyfomod.fomod.Files object at 0x7f2d77c68b80>
print(list(option1.files))
# ['02 ESPs\\AIO/', '00 Common/', '01 Characters\\Camilla/', '01 Characters\\Grelka/', '01 Characters\\Morwen/', '01 Characters\\Muiri/', '01 Characters\\Senna/', '01 Characters\\Sylgja/', '01 Characters\\Taarie/', '01 Characters\\Temba/', '01 Characters\\Ysolda/']
However, when I actually select that option with the installer, it only remembers the last path:
mod = pyfomod.parse((None,"./ModuleConfig.xml"))
installer = pyfomod.Installer(mod)
page1 = installer.next()
group1 = page1[0]
option1 = group1[0]
print(option1.name)
# All IN ONE
installer.next([option1])
print(installer.files())
# {'01 Characters\\Ysolda': '.'}
From multiple test cases, this seems to be always the last file added - and not just per page or group, but over the entire installer.
I did some digging through the code and I'm not sure I fully understand it, but it seems the source -> destination file dict is first built in reverse (as a destination -> source dict)
pyfomod/src/pyfomod/installer.py
Lines 267 to 276 in 9c27b5c
This leads to paths with duplicate destinations being ignored, which breaks if the fomod uses directory destinations (copying whole directories instead of individual files).
Removing that whole logic fixes the issue, but obviously breaks the priority calculation.