Fix gen_contents_index when not run inplace; trac #2764