Use completed_streams and total_streams in extract progress
authorEric Biggers <ebiggers3@gmail.com>
Wed, 25 Jun 2014 01:46:03 +0000 (20:46 -0500)
committerEric Biggers <ebiggers3@gmail.com>
Wed, 25 Jun 2014 01:46:03 +0000 (20:46 -0500)
include/wimlib.h
include/wimlib/apply.h
src/extract.c

index f56e72cf0047585db6eb4995d5d2b282ab46953f..9c043c1ba5d31e2d112c4ba8997ec481508bc832 100644 (file)
@@ -895,10 +895,11 @@ union wimlib_progress_info {
                 * potentially multiple streams per file (named data streams).
                 * A "stream" may be the default contents of a file, a named
                 * data stream, or a reparse data buffer.  */
-               uint64_t num_streams;
+               uint64_t total_streams;
 
-               /** Reserved.  */
-               const wimlib_tchar *reserved_2;
+               /** Number of (not necessarily unique) streams that have been
+                * extracted so far.  */
+               uint64_t completed_streams;
 
                /** Currently only used for
                 * ::WIMLIB_PROGRESS_MSG_EXTRACT_SPWM_PART_BEGIN.  */
index 9f5f86bd4a9813dfc00af01eac886a58148446fb..2f3b1cb941ab3b61a8821357f2cf2091d50a4f72 100644 (file)
@@ -67,6 +67,7 @@ struct apply_ctx {
        struct list_head stream_list;
        const struct read_stream_list_callbacks *saved_cbs;
        struct wim_lookup_table_entry *cur_stream;
+       u64 cur_stream_offset;
        struct filedes tmpfile_fd;
        tchar *tmpfile_name;
 };
index bbd0a5ed6801276a98a9b4b9ca4a3b92d5eba5ee..0663edd75ba92d4f736b8249d572b292e0adc04b 100644 (file)
@@ -311,6 +311,7 @@ begin_extract_stream_wrapper(struct wim_lookup_table_entry *lte, void *_ctx)
        struct apply_ctx *ctx = _ctx;
 
        ctx->cur_stream = lte;
+       ctx->cur_stream_offset = 0;
 
        if (unlikely(lte->out_refcnt > MAX_OPEN_STREAMS))
                return create_temporary_file(&ctx->tmpfile_fd, &ctx->tmpfile_name);
@@ -325,9 +326,13 @@ extract_chunk_wrapper(const void *chunk, size_t size, void *_ctx)
        union wimlib_progress_info *progress = &ctx->progress;
        int ret;
 
+       ctx->cur_stream_offset += size;
+
        if (likely(ctx->supported_features.hard_links)) {
                progress->extract.completed_bytes +=
                        (u64)size * ctx->cur_stream->out_refcnt;
+               if (ctx->cur_stream_offset == ctx->cur_stream->size)
+                       progress->extract.completed_streams += ctx->cur_stream->out_refcnt;
        } else {
                const struct stream_owner *owners = stream_owners(ctx->cur_stream);
                for (u32 i = 0; i < ctx->cur_stream->out_refcnt; i++) {
@@ -339,6 +344,8 @@ extract_chunk_wrapper(const void *chunk, size_t size, void *_ctx)
                                            d_extraction_alias_node)
                        {
                                progress->extract.completed_bytes += size;
+                               if (ctx->cur_stream_offset == ctx->cur_stream->size)
+                                       progress->extract.completed_streams++;
                        }
                }
        }
@@ -961,7 +968,7 @@ ref_stream(struct wim_lookup_table_entry *lte, u32 stream_idx,
                return 0;
 
        ctx->progress.extract.total_bytes += lte->size;
-       ctx->progress.extract.num_streams++;
+       ctx->progress.extract.total_streams++;
 
        if (inode->i_visited)
                return 0;