protected function replace_tempdir() {
        global $CFG;

        $tempdir = $this->get_tempdir_path();

        if (empty($CFG->keeptempdirectoriesonbackup)) {
            fulldelete($tempdir);
        } else {
            if (!rename($tempdir, $tempdir . '_' . $this->get_name() . '_' . $this->id . '_source')) {
                throw new convert_exception('failed_rename_source_tempdir');
            }
        }

        if (!rename($this->get_workdir_path(), $tempdir)) {
            throw new convert_exception('failed_move_converted_into_place');
        }
    }