Downloaded files with duplicate names are overwriting each other
Try to replicate this bug only. Do not try to fix. I suspect that it is a part of a larger problem.
With music files for example the directory will often contain the name 'cover.jpg' or 'booklet.jpg' for scans of print material that was included in the original album. MuWire does not seem to handle this well. What I am seeing is when MuWire tries to download multiple files with identical names into the Download directory it seems to overwrite any existing file with the same names.
The simple fix of renaming by a number to the end of the filename is what file managers tend to do when trying to copy the files of the same name into the same location. This will corrupt the users collection and break up the swarm by corrupting files so that identical files from different users do not hash to the same value. Consequently they will no longer be able to both act as sources for what was originally the same file.
The solution as I see it will be to come up with a mechanism for recreating not just the file but also the original owners directory that contained the file.
For example the uploader had a directory of an album. That directory contained several audio files and a subdirectory called scans. The scans directory had files called 'cover.jpg', 'back.jpg' and 'cover.jpg'. That same uploader or some other uploader had a directory of a different album with the same subdirectory and containing files of the same names. When the downloader downloads the second set of files they are overwritten in his MuWire 'Download' folder. The solution would be to recreate the directories nested as they were on the uploaders file system so that files of the same name ended up in unique locations.
The fix would be more complicated than that but for now we just need to verify that this occurs and can be replicated.