Fix extract progress messages (again)
authorEric Biggers <ebiggers3@gmail.com>
Wed, 19 Dec 2012 06:07:08 +0000 (00:07 -0600)
committerEric Biggers <ebiggers3@gmail.com>
Wed, 19 Dec 2012 06:07:08 +0000 (00:07 -0600)
programs/imagex.c
src/extract_image.c

index 7cfc91c087bb66e6914b9031fcd4f2ec3e96ae04..93c4d29761d89295898d212782c02b0b8381fd95 100644 (file)
@@ -361,7 +361,7 @@ static int imagex_progress_func(enum wimlib_progress_msg msg,
                       info->write_streams.completed_bytes >> 20,
                       info->write_streams.total_bytes >> 20,
                       percent_done);
-               if (info->write_streams.completed_bytes == info->write_streams.total_bytes)
+               if (info->write_streams.completed_bytes >= info->write_streams.total_bytes)
                        putchar('\n');
                break;
        case WIMLIB_PROGRESS_MSG_SCAN_BEGIN:
@@ -426,7 +426,7 @@ static int imagex_progress_func(enum wimlib_progress_msg msg,
                       info->extract.completed_bytes >> 20,
                       info->extract.total_bytes >> 20,
                       percent_done);
-               if (info->extract.completed_bytes == info->extract.total_bytes)
+               if (info->extract.completed_bytes >= info->extract.total_bytes)
                        putchar('\n');
                break;
        case WIMLIB_PROGRESS_MSG_EXTRACT_DENTRY:
index ba9b8c675d47e90dd98c70e502236330dcfbf199..56c72f870e0947e7c5d05177c5f5228aa647e508 100644 (file)
@@ -546,12 +546,20 @@ static int apply_stream_list(struct list_head *stream_list,
                                if (ret != 0)
                                        goto out;
                                if (progress_func &&
-                                   args->progress.extract.completed_bytes >= next_progress &&
-                                   args->progress.extract.total_bytes != 0)
+                                   args->progress.extract.completed_bytes >= next_progress)
                                {
                                        progress_func(WIMLIB_PROGRESS_MSG_EXTRACT_STREAMS,
                                                      &args->progress);
-                                       next_progress += bytes_per_progress;
+                                       if (args->progress.extract.completed_bytes >=
+                                           args->progress.extract.total_bytes)
+                                       {
+                                               next_progress = ~0ULL;
+                                       } else {
+                                               next_progress =
+                                                       min (args->progress.extract.completed_bytes +
+                                                            bytes_per_progress,
+                                                            args->progress.extract.total_bytes);
+                                       }
                                }
                        }
                }