Closed codewithmichael closed 9 years ago
I'd like to see if I can refactor the new functionality into two new functions since they're basically just doing the same thing twice on different directories. It might be a little ugly extracting the kernel version number string within the generate function once everything else is abstracted away, so I may add a third function for that as well.
As I was starting the refactor I noticed that, without the recursive generate
call, the new code finds unversioned image pairs in the preferred directory but bot the fallback directory. I'll fix that first.
After fixing the fallback directory unversioned image pair issue, the code between preferred and fallback directory checks is significantly different enough that refactoring into external methods would actually make the code longer and more complex, so I don't think further refactoring is required at this time.
I think this is ready to go.
This fixes issue #1.
I replaced the recursive generate calls for the kernel and initrd lookups with separate internal checks to the preferred and fallback directories for each image. This ensures that the directories used for the kernel image and initrd image are searched individually. The kernel version is still determined first and used in finding a matching initrd.img file.
The one exception to the aforementioned split directory search is if the preferred directory contains two unversioned images (as regularly happens in the boot/images directory via symlinks). In that case — when there's an unversioned kernel and initrd image in the same directory — no further search is performed and the unversioned file paths are used.
A single recursive generate call still exists in case the preferred directory isn't defined or doesn't exist.