Fix bug DNN-5224: rollback previous change, and check whether oldfile is null instead of fileExists.