repository: return path length in discover

Return the path length à la snprintf so the caller can know the
expected length of the path.