-/* Ideally this would be unnecessary... however, the WIMs for Windows 8 are
- * screwed up because some lookup table entries are referenced more times than
- * their stated reference counts. So theoretically, if we delete all the
- * references to a stream and then remove it, it might still be referenced
- * somewhere else, making a file be missing from the WIM... So, work around this
- * problem by looking at ALL the images to re-calculate the reference count of
- * EVERY lookup table entry. This only absolutely has to be done before an image
- * is deleted or before an image is mounted read-write. */
-void
-wim_recalculate_refcnts(WIMStruct *wim)
-{
- unsigned long num_ltes_with_bogus_refcnt = 0;
-
- for_lookup_table_entry(wim->lookup_table, lte_zero_real_refcnt, NULL);
- for_image(wim, WIMLIB_ALL_IMAGES, tally_image_refcnts);
- num_ltes_with_bogus_refcnt = 0;
- for_lookup_table_entry(wim->lookup_table, lte_fix_refcnt,
- &num_ltes_with_bogus_refcnt);
- if (num_ltes_with_bogus_refcnt != 0) {
- WARNING("A total of %lu entries in the WIM's stream "
- "lookup table had to have\n"
- " their reference counts fixed.",
- num_ltes_with_bogus_refcnt);
+ if (wim_has_metadata(wim)) {
+
+ memset(&progress, 0, sizeof(progress));
+ progress.verify_image.wimfile = wim->filename;
+ progress.verify_image.total_images = wim->hdr.image_count;
+
+ for (int i = 1; i <= wim->hdr.image_count; i++) {
+
+ progress.verify_image.current_image = i;
+
+ ret = call_progress(wim->progfunc, WIMLIB_PROGRESS_MSG_BEGIN_VERIFY_IMAGE,
+ &progress, wim->progctx);
+ if (ret)
+ return ret;
+
+ ret = select_wim_image(wim, i);
+ if (ret)
+ return ret;
+
+ ret = verify_image_streams_present(wim_get_current_image_metadata(wim),
+ wim->lookup_table);
+ if (ret)
+ return ret;
+
+ ret = call_progress(wim->progfunc, WIMLIB_PROGRESS_MSG_END_VERIFY_IMAGE,
+ &progress, wim->progctx);
+ if (ret)
+ return ret;
+ }
+ } else {
+ WARNING("\"%"TS"\" does not contain image metadata. Skipping image verification.",
+ wim->filename);
+ }
+
+ /* Verify the streams */
+
+ for_lookup_table_entry(wim->lookup_table, append_lte_to_list, &stream_list);
+
+ memset(&progress, 0, sizeof(progress));
+
+ progress.verify_streams.wimfile = wim->filename;
+ list_for_each_entry(lte, &stream_list, extraction_list) {
+ progress.verify_streams.total_streams++;
+ progress.verify_streams.total_bytes += lte->size;