Skip to content
This repository was archived by the owner on May 24, 2026. It is now read-only.

Commit 081446b

Browse files
caesayclaude
andcommitted
Fix empty cabinet creation in CabFlush
When no files are added to a cabinet (total_files == 0), CabFlush previously returned success without creating any file. This caused WiX's file transfer system to fail with FileNotFoundException when trying to move the expected cabinet to the output directory. Now creates a valid empty cabinet file (cabinet with an empty folder) and reports it back to the caller, matching the behavior expected by WiX for declared-but-empty cabinets. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 1442b60 commit 081446b

1 file changed

Lines changed: 19 additions & 1 deletion

File tree

msi-interop/msi_cab.c

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,25 @@ CabFlush(CABHANDLE handle,
348348

349349
guint total_files = ctx->files->len;
350350
if (total_files == 0) {
351-
/* No files added -- nothing to write */
351+
/* Create an empty cabinet file (valid cabinet with no files). */
352+
GError *error = NULL;
353+
gboolean ok = write_single_cabinet(ctx, 0, 0, ctx->output_path, &error);
354+
g_clear_error(&error);
355+
356+
if (!ok)
357+
return CAB_ERROR_FUNCTION_FAILED;
358+
359+
/* Report the single empty cabinet */
360+
WCHAR *cab_name_w = utf8_to_utf16(ctx->cab_basename, NULL);
361+
WCHAR *empty_token_w = utf8_to_utf16("", NULL);
362+
g_ptr_array_add(ctx->result_cab_names, cab_name_w);
363+
g_ptr_array_add(ctx->result_tokens, empty_token_w);
364+
365+
if (out_cabs != NULL && max_cabs > 0) {
366+
out_cabs[0].cabinet_name = (const wchar_t *)g_ptr_array_index(ctx->result_cab_names, 0);
367+
out_cabs[0].first_file_token = (const wchar_t *)g_ptr_array_index(ctx->result_tokens, 0);
368+
}
369+
*out_count = 1;
352370
return CAB_SUCCESS;
353371
}
354372

0 commit comments

Comments
 (0)