spacewalkproject/spacewalk — pull request #22 by SilvioMoioli (2014-03-24 17:44:23+00:00)
Title: Fix rhn_erratafile_eid_file_uq violation

`rhnErrataFile.filename` can get duplicate values from the Java code, because it uses the package NEVRA instead of the real file path. It may happen that different packages with different IDs get the same NEVRA, for example, when two repositories that contain the same software for different architectures have a "semi-identical" noarch package. Thus any patch that affects that package will end up having both, and publishing it will result in the constraint violation.

We verified this bug with spacecmd softwarechannel_adderratabydate and spacewalk-clone-by-date.

Moreover, Java and Perl codebases treat this column differently, with the Perl part using the package full path (taken from rhnPackage.filename) instead of the NEVRA. This is safer because package path contains the package checksum, so we decided to take that convention and use it also in the Java part.

I also added a couple of patches to handle the unlikely case that rhnPackage.path is NULL, which can only happen if a spacewalk-fsck was run but could not find some packages.