Only set length if the resource exists.