code: def finalize_file(self):
          # type: (Descriptor) -> None
          
          # delete bad file if integrity failed
          if self._integrity_failed:
              self.final_path.unlink()
          else:
              self._restore_file_attributes()
              self._restore_file_lmt()
          # update resume file
          self._update_resume_for_completed()
          with self._meta_lock:
              self._finalized = True
docs: Finalize file for download
          :param Descriptor self: this