Modify copy_unique_file to return existed id