add lock to copy_files