From: Eric Biggers Date: Mon, 3 Apr 2023 05:36:40 +0000 (-0700) Subject: wimoptimize: better defaults for WIM <=> ESD X-Git-Tag: v1.14.0~10 X-Git-Url: https://wimlib.net/git/?a=commitdiff_plain;h=592ccb68a5be84a00b00e67fbfff81cc27ccbf52;p=wimlib wimoptimize: better defaults for WIM <=> ESD Resolves https://wimlib.net/forums/viewtopic.php?t=508 Resolves https://wimlib.net/forums/viewtopic.php?t=654 --- diff --git a/NEWS.md b/NEWS.md index 87c28d71..ca380763 100644 --- a/NEWS.md +++ b/NEWS.md @@ -23,6 +23,13 @@ - `wimupdate` now supports the `--ref` option. It should be specified when updating a delta WIM to avoid two minor issues. +- `wimoptimize` now has better default behavior when converting to and from + solid archives, i.e. WIM <=> ESD. It now is consistent with `wimcapture` and + `wimexport`. For WIM => ESD, `wimoptimize --solid` now works. Before, the + needed command was `wimoptimize --solid --compress=LZMS --chunk-size=128K`. + For ESD => WIM, `wimoptimize --compress=LZX` now works. Before, the needed + command was `wimoptimize --compress=LZX --chunk-size=32K`. + - Removed support for Windows XP. - Added a GitHub Actions workflow that tests wimlib. diff --git a/doc/man1/wimoptimize.1 b/doc/man1/wimoptimize.1 index d4758719..628918fa 100644 --- a/doc/man1/wimoptimize.1 +++ b/doc/man1/wimoptimize.1 @@ -124,6 +124,14 @@ wimoptimize install.wim --solid .br mv install.wim install.esd .RE +.PP +Turn 'install.esd' back into 'install.wim': +.RS +.PP +wimoptimize install.wim --compress=LZX +.br +mv install.esd install.wim +.RE .SH SEE ALSO .BR wimlib-imagex (1) .BR wimexport (1) diff --git a/programs/imagex.c b/programs/imagex.c index f1434bf2..f053cd74 100644 --- a/programs/imagex.c +++ b/programs/imagex.c @@ -3857,6 +3857,7 @@ imagex_optimize(int argc, tchar **argv, int cmd) int solid_ctype = WIMLIB_COMPRESSION_TYPE_INVALID; int ret; WIMStruct *wim; + struct wimlib_wim_info info; const tchar *wimfile; off_t old_size; off_t new_size; @@ -3900,6 +3901,9 @@ imagex_optimize(int argc, tchar **argv, int cmd) case IMAGEX_SOLID_OPTION: write_flags |= WIMLIB_WRITE_FLAG_SOLID; write_flags |= WIMLIB_WRITE_FLAG_RECOMPRESS; + /* Reset the non-solid compression type to LZMS. */ + if (compression_type == WIMLIB_COMPRESSION_TYPE_INVALID) + compression_type = WIMLIB_COMPRESSION_TYPE_LZMS; break; case IMAGEX_NO_SOLID_SORT_OPTION: write_flags |= WIMLIB_WRITE_FLAG_NO_SOLID_SORT; @@ -3935,11 +3939,18 @@ imagex_optimize(int argc, tchar **argv, int cmd) if (ret) goto out; - if (compression_type != WIMLIB_COMPRESSION_TYPE_INVALID) { + wimlib_get_wim_info(wim, &info); + + if (compression_type != WIMLIB_COMPRESSION_TYPE_INVALID && + compression_type != info.compression_type) { /* Change compression type. */ ret = wimlib_set_output_compression_type(wim, compression_type); if (ret) goto out_wimlib_free; + + /* Reset the chunk size. */ + if (chunk_size == UINT32_MAX) + chunk_size = 0; } if (chunk_size != UINT32_MAX) {