+ if (blob->blob_location == BLOB_IN_WIM)
+ blob_stored_size = blob->rdesc->size_in_wim;
+ else
+ blob_stored_size = blob->size;
+
+ /* Start the next part if adding this blob exceeds the maximum part
+ * size, UNLESS the blob is metadata or if no blobs at all have been
+ * added to the current part. */
+ if ((swm_info->parts[swm_info->num_parts - 1].size +
+ blob_stored_size >= swm_info->max_part_size)
+ && !(blob->is_metadata ||
+ swm_info->parts[swm_info->num_parts - 1].size == 0))
+ {
+ ret = start_new_swm_part(swm_info);
+ if (ret)
+ return ret;
+ }
+ swm_info->parts[swm_info->num_parts - 1].size += blob_stored_size;
+ if (!blob->is_metadata) {
+ list_add_tail(&blob->write_blobs_list,
+ &swm_info->parts[swm_info->num_parts - 1].blob_list);
+ }
+ swm_info->total_bytes += blob_stored_size;
+ return 0;
+}