]> wimlib.net Git - wimlib/blobdiff - src/write.c
win32_common.c: Remove duplicate declaration of func_NtOpenFile
[wimlib] / src / write.c
index f34481aae2525b62274b9d7e9705938fd231319c..ae1754803628f8f2f433568d05453fba28444ed6 100644 (file)
@@ -1536,6 +1536,18 @@ out_destroy_context:
        return ret;
 }
 
+static int
+is_stream_packed(struct wim_lookup_table_entry *lte, void *_ignore)
+{
+       return lte_is_partial(lte);
+}
+
+static bool
+wim_has_packed_streams(WIMStruct *wim)
+{
+       return for_lookup_table_entry(wim->lookup_table, is_stream_packed, NULL);
+}
+
 static int
 wim_write_stream_list(WIMStruct *wim,
                      struct list_head *stream_list,
@@ -1550,10 +1562,15 @@ wim_write_stream_list(WIMStruct *wim,
 
        write_resource_flags = write_flags_to_resource_flags(write_flags);
 
-       /* wimlib v1.6.3: pack streams by default if the WIM version number is
-        * that usually used in solid archives.  */
-       if (wim->hdr.wim_version == WIM_VERSION_PACKED_STREAMS)
+       /* wimlib v1.6.3: pack streams by default if the WIM version has been
+        * set to WIM_VERSION_PACKED_STREAMS and at least one stream in the
+        * WIM's lookup table is located in a packed resource (may be the same
+        * WIM, or a different one in the case of export).  */
+       if (wim->hdr.wim_version == WIM_VERSION_PACKED_STREAMS &&
+           wim_has_packed_streams(wim))
+       {
                write_resource_flags |= WRITE_RESOURCE_FLAG_PACK_STREAMS;
+       }
 
        if (write_resource_flags & WRITE_RESOURCE_FLAG_PACK_STREAMS) {
                out_chunk_size = wim->out_pack_chunk_size;
@@ -1908,7 +1925,7 @@ filter_stream_list_for_write(struct list_head *stream_list,
  *     @stream_list_ret.
  *
  *     SKIP_EXTERNAL_WIMS:  Streams already present in a WIM file, but not
- *     @wim, shall be be returned in neither @stream_list_ret nor
+ *     @wim, shall be returned in neither @stream_list_ret nor
  *     @lookup_table_list_ret.
  *
  * @stream_list_ret
@@ -2616,9 +2633,9 @@ write_wim_part(WIMStruct *wim,
                DEBUG("Number of threads: %u", num_threads);
        DEBUG("Progress function: %s", (progress_func ? "yes" : "no"));
        DEBUG("Stream list:       %s", (stream_list_override ? "specified" : "autodetect"));
-       DEBUG("GUID:              %s", (guid ||
-                                       (write_flags & WIMLIB_WRITE_FLAG_RETAIN_GUID)) ?
-                                       "explicit" : "generate new");
+       DEBUG("GUID:              %s", (write_flags &
+                                       WIMLIB_WRITE_FLAG_RETAIN_GUID) ? "retain"
+                                               : guid ? "explicit" : "generate new");
 
        /* Internally, this is always called with a valid part number and total
         * parts.  */
@@ -2714,11 +2731,13 @@ write_wim_part(WIMStruct *wim,
        /* Set chunk size if different.  */
        wim->hdr.chunk_size = wim->out_chunk_size;
 
-       /* Use GUID if specified; otherwise generate a new one.  */
-       if (guid)
-               memcpy(wim->hdr.guid, guid, WIMLIB_GUID_LEN);
-       else if (!(write_flags & WIMLIB_WRITE_FLAG_RETAIN_GUID))
-               randomize_byte_array(wim->hdr.guid, WIMLIB_GUID_LEN);
+       /* Set GUID.  */
+       if (!(write_flags & WIMLIB_WRITE_FLAG_RETAIN_GUID)) {
+               if (guid)
+                       memcpy(wim->hdr.guid, guid, WIMLIB_GUID_LEN);
+               else
+                       randomize_byte_array(wim->hdr.guid, WIMLIB_GUID_LEN);
+       }
 
        /* Clear references to resources that have not been written yet.  */
        zero_reshdr(&wim->hdr.lookup_table_reshdr);
@@ -2949,7 +2968,7 @@ check_resource_offsets(WIMStruct *wim, off_t end_offset)
  *                   Integrity table (optional) (variable size)
  *
  * This method allows an image to be appended to a large WIM very quickly, and
- * is is crash-safe except in the case of write re-ordering, but the
+ * is crash-safe except in the case of write re-ordering, but the
  * disadvantage is that a small hole is left in the WIM where the old lookup
  * table, xml data, and integrity table were.  (These usually only take up a
  * small amount of space compared to the streams, however.)