X-Git-Url: https://wimlib.net/git/?p=wimlib;a=blobdiff_plain;f=src%2Fblob_table.c;fp=src%2Fblob_table.c;h=96290e8de777afef6137f0e4d45433d5823e6e67;hp=40c4af4bd023281157a4a653609c99ead554f961;hb=cf13fe6161a69db6cbf17637b60c978fd746078a;hpb=fc938fc3886f0c8cacdbc83148484b55a32ca8e7 diff --git a/src/blob_table.c b/src/blob_table.c index 40c4af4b..96290e8d 100644 --- a/src/blob_table.c +++ b/src/blob_table.c @@ -403,7 +403,12 @@ cmp_blobs_by_sequential_order(const void *p1, const void *p2) v = (int)blob1->blob_location - (int)blob2->blob_location; - /* Different locations? */ + /* Different locations? Note: "unsafe compaction mode" requires that + * blobs in WIMs sort before all others. For the logic here to ensure + * this, BLOB_IN_WIM must have the lowest value among all defined + * blob_locations. Statically verify that the enum values haven't + * changed. */ + STATIC_ASSERT(BLOB_NONEXISTENT == 0 && BLOB_IN_WIM == 1); if (v) return v; @@ -415,6 +420,12 @@ cmp_blobs_by_sequential_order(const void *p1, const void *p2) /* Different WIM files? */ if (wim1 != wim2) { + /* Resources from the WIM file currently being compacted + * (if any) must always sort first. */ + v = (int)wim2->being_compacted - (int)wim1->being_compacted; + if (v) + return v; + /* Different split WIMs? */ v = cmp_guids(wim1->hdr.guid, wim2->hdr.guid); if (v)