]> wimlib.net Git - wimlib/commitdiff
wimoptimize: better defaults for WIM <=> ESD
authorEric Biggers <ebiggers3@gmail.com>
Mon, 3 Apr 2023 05:36:40 +0000 (22:36 -0700)
committerEric Biggers <ebiggers3@gmail.com>
Mon, 3 Apr 2023 05:53:20 +0000 (22:53 -0700)
Resolves https://wimlib.net/forums/viewtopic.php?t=508
Resolves https://wimlib.net/forums/viewtopic.php?t=654

NEWS.md
doc/man1/wimoptimize.1
programs/imagex.c

diff --git a/NEWS.md b/NEWS.md
index 87c28d71d9eb5f72ce96c91a2d05a58b47639bd0..ca380763204c14ec9ef4c0ad4ee92276230bf357 100644 (file)
--- a/NEWS.md
+++ b/NEWS.md
 - `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.
index d4758719a8500a6972f80b536e45ea4dde8e7d2b..628918faa6b181be084fe034f0ac0361975128a2 100644 (file)
@@ -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)
index f1434bf2c8948b3577ce46d5d5c0ff3b9dd4cbc4..f053cd74bcddd7019c9541c98c48596e903cc67d 100644 (file)
@@ -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) {