fix bug replace same name file

fix file deletion while replacing file with one with the same name