def _prepare_data_dir(self, data):
        """Prepare destination directory where the data will live.

        :param data: The :class:`~resolwe.flow.models.Data` object for
            which to prepare the private execution directory.
        :return: The prepared data directory path.
        :rtype: str
        """
        logger.debug(__("Preparing data directory for Data with id {}.", data.id))

        with transaction.atomic():
            # Create a temporary random location and then override it with data
            # location id since object has to be created first.
            # TODO Find a better solution, e.g. defer the database constraint.
            temporary_location_string = uuid.uuid4().hex[:10]
            data_location = DataLocation.objects.create(subpath=temporary_location_string)
            data_location.subpath = str(data_location.id)
            data_location.save()
            data_location.data.add(data)

        output_path = self._get_per_data_dir('DATA_DIR', data_location.subpath)
        dir_mode = self.settings_actual.get('FLOW_EXECUTOR', {}).get('DATA_DIR_MODE', 0o755)
        os.mkdir(output_path, mode=dir_mode)
        # os.mkdir is not guaranteed to set the given mode
        os.chmod(output_path, dir_mode)
        return output_path
Prepare destination directory where the data will live.

        :param data: The :class:`~resolwe.flow.models.Data` object for
            which to prepare the private execution directory.
        :return: The prepared data directory path.
        :rtype: str