Made sure we only save last build cache as being empty when we should be

- Made sure we check all codebase+branch types when saving a build incase they are not in the original order