X-Git-Url: https://wimlib.net/git/?a=blobdiff_plain;f=programs%2Fimagex.c;h=b7ff47ef14aa829eb2a75190e13d99c60c0dfa3f;hb=f84a3d108722a2290f45d384638206663a9df824;hp=23f362b61f2beb524e3a53747cd34f94669cac2e;hpb=3bdac428d5dfb5c609b8012e4a6a1df7a7eb91dd;p=wimlib diff --git a/programs/imagex.c b/programs/imagex.c index 23f362b6..b7ff47ef 100644 --- a/programs/imagex.c +++ b/programs/imagex.c @@ -1958,6 +1958,11 @@ imagex_capture_or_append(int argc, tchar **argv, int cmd) add_flags |= WIMLIB_ADD_FLAG_WIMBOOT; break; case IMAGEX_UNSAFE_COMPACT_OPTION: + if (cmd != CMD_APPEND) { + imagex_error(T("'--unsafe-compact' is only " + "valid for append!")); + goto out_err; + } write_flags |= WIMLIB_WRITE_FLAG_UNSAFE_COMPACT; break; default: @@ -2117,11 +2122,21 @@ imagex_capture_or_append(int argc, tchar **argv, int cmd) ret = wimlib_set_output_chunk_size(wim, chunk_size); if (ret) goto out_free_wim; - } else if ((add_flags & WIMLIB_ADD_FLAG_WIMBOOT) && - compression_type == WIMLIB_COMPRESSION_TYPE_XPRESS) { - ret = wimlib_set_output_chunk_size(wim, 4096); - if (ret) - goto out_free_wim; + } else if ((add_flags & WIMLIB_ADD_FLAG_WIMBOOT)) { + + int ctype = compression_type; + + if (cmd == CMD_APPEND) { + struct wimlib_wim_info info; + wimlib_get_wim_info(wim, &info); + ctype = info.compression_type; + } + + if (ctype == WIMLIB_COMPRESSION_TYPE_XPRESS) { + ret = wimlib_set_output_chunk_size(wim, 4096); + if (ret) + goto out_free_wim; + } } if (solid_ctype != WIMLIB_COMPRESSION_TYPE_INVALID) { ret = wimlib_set_output_pack_compression_type(wim, solid_ctype); @@ -2941,6 +2956,13 @@ imagex_export(int argc, tchar **argv, int cmd) goto out_free_src_wim; } + if (write_flags & WIMLIB_WRITE_FLAG_UNSAFE_COMPACT) { + imagex_error(T("'--unsafe-compact' is only valid when " + "exporting to an existing WIM file!")); + ret = -1; + goto out_free_src_wim; + } + /* dest_wimfile is not an existing file, so create a new WIM. */ if (compression_type == WIMLIB_COMPRESSION_TYPE_INVALID) {