X-Git-Url: https://wimlib.net/git/?p=wimlib;a=blobdiff_plain;f=src%2Fwrite.c;h=c1d56de3001d1a37d166d22ec6daa9ee6dce163e;hp=4d5e71651abceb3d411b3549d094705f28693827;hb=c86d5f74e13e5aeff57aff84f7d65264607a29ac;hpb=3df2989aaef4c627f4fea630859ae9f72e9c307e diff --git a/src/write.c b/src/write.c index 4d5e7165..c1d56de3 100644 --- a/src/write.c +++ b/src/write.c @@ -300,8 +300,8 @@ do_write_blobs_progress(struct write_blobs_progress_data *progress_data, progress->write_streams.completed_streams += complete_count; } - if (progress->write_streams.completed_bytes >= progress_data->next_progress) - { + if (progress->write_streams.completed_bytes >= progress_data->next_progress) { + ret = call_progress(progress_data->progfunc, WIMLIB_PROGRESS_MSG_WRITE_STREAMS, progress, @@ -309,32 +309,9 @@ do_write_blobs_progress(struct write_blobs_progress_data *progress_data, if (ret) return ret; - if (progress_data->next_progress == progress->write_streams.total_bytes) { - progress_data->next_progress = ~(u64)0; - } else { - /* Handle rate-limiting of messages */ - - /* Send new message as soon as another 1/128 of the - * total has been written. (Arbitrary number.) */ - progress_data->next_progress = - progress->write_streams.completed_bytes + - progress->write_streams.total_bytes / 128; - - /* ... Unless that would be more than 5000000 bytes, in - * which case send the next after the next 5000000 - * bytes. (Another arbitrary number.) */ - if (progress->write_streams.completed_bytes + 5000000 < - progress_data->next_progress) - progress_data->next_progress = - progress->write_streams.completed_bytes + 5000000; - - /* ... But always send a message as soon as we're - * completely done. */ - if (progress->write_streams.total_bytes < - progress_data->next_progress) - progress_data->next_progress = - progress->write_streams.total_bytes; - } + set_next_progress(progress->write_streams.completed_bytes, + progress->write_streams.total_bytes, + &progress_data->next_progress); } return 0; } @@ -647,6 +624,8 @@ do_done_with_blob(struct blob_descriptor *blob, { int ret; struct wim_inode *inode; + tchar *cookie1; + tchar *cookie2; if (!blob->may_send_done_with_file) return 0; @@ -654,42 +633,18 @@ do_done_with_blob(struct blob_descriptor *blob, inode = blob->file_inode; wimlib_assert(inode != NULL); - wimlib_assert(inode->num_remaining_streams > 0); - if (--inode->num_remaining_streams > 0) + wimlib_assert(inode->i_num_remaining_streams > 0); + if (--inode->i_num_remaining_streams > 0) return 0; -#ifdef __WIN32__ - /* XXX: This logic really should be somewhere else. */ - - /* We want the path to the file, but blob->file_on_disk might actually - * refer to a named data stream. Temporarily strip the named data - * stream from the path. */ - wchar_t *p_colon = NULL; - wchar_t *p_question_mark = NULL; - const wchar_t *p_stream_name; - - p_stream_name = path_stream_name(blob->file_on_disk); - if (unlikely(p_stream_name)) { - p_colon = (wchar_t *)(p_stream_name - 1); - wimlib_assert(*p_colon == L':'); - *p_colon = L'\0'; - } - - /* We also should use a fake Win32 path instead of a NT path */ - if (!wcsncmp(blob->file_on_disk, L"\\??\\", 4)) { - p_question_mark = &blob->file_on_disk[1]; - *p_question_mark = L'\\'; - } -#endif + cookie1 = progress_get_streamless_path(blob->file_on_disk); + cookie2 = progress_get_win32_path(blob->file_on_disk); ret = done_with_file(blob->file_on_disk, progfunc, progctx); -#ifdef __WIN32__ - if (p_colon) - *p_colon = L':'; - if (p_question_mark) - *p_question_mark = L'?'; -#endif + progress_put_win32_path(cookie2); + progress_put_streamless_path(cookie1); + return ret; } @@ -795,7 +750,7 @@ write_blob_uncompressed(struct blob_descriptor *blob, struct filedes *out_fd) if (filedes_seek(out_fd, begin_offset) == -1) return 0; - ret = extract_full_blob_to_fd(blob, out_fd); + ret = extract_blob_to_fd(blob, out_fd); if (ret) { /* Error reading the uncompressed data. */ if (out_fd->offset == begin_offset && @@ -1333,19 +1288,13 @@ finish_remaining_chunks(struct write_blobs_ctx *ctx) } static void -remove_empty_blobs(struct list_head *blob_list) +validate_blob_list(struct list_head *blob_list) { - struct blob_descriptor *blob, *tmp; + struct blob_descriptor *blob; - list_for_each_entry_safe(blob, tmp, blob_list, write_blobs_list) { + list_for_each_entry(blob, blob_list, write_blobs_list) { wimlib_assert(blob->will_be_in_output_wim); - if (blob->size == 0) { - list_del(&blob->write_blobs_list); - blob->out_reshdr.offset_in_wim = 0; - blob->out_reshdr.size_in_wim = 0; - blob->out_reshdr.uncompressed_size = 0; - blob->out_reshdr.flags = reshdr_flags_for_blob(blob); - } + wimlib_assert(blob->size != 0); } } @@ -1367,7 +1316,7 @@ init_done_with_file_info(struct list_head *blob_list) list_for_each_entry(blob, blob_list, write_blobs_list) { if (blob_is_in_file(blob)) { - blob->file_inode->num_remaining_streams = 0; + blob->file_inode->i_num_remaining_streams = 0; blob->may_send_done_with_file = 1; } else { blob->may_send_done_with_file = 0; @@ -1376,7 +1325,7 @@ init_done_with_file_info(struct list_head *blob_list) list_for_each_entry(blob, blob_list, write_blobs_list) if (blob->may_send_done_with_file) - blob->file_inode->num_remaining_streams++; + blob->file_inode->i_num_remaining_streams++; } /* @@ -1504,7 +1453,7 @@ write_blob_list(struct list_head *blob_list, (WRITE_RESOURCE_FLAG_SOLID | WRITE_RESOURCE_FLAG_PIPABLE)); - remove_empty_blobs(blob_list); + validate_blob_list(blob_list); if (list_empty(blob_list)) return 0; @@ -1615,13 +1564,11 @@ write_blob_list(struct list_head *blob_list, /* Read the list of blobs needing to be compressed, using the specified * callbacks to execute processing of the data. */ - struct read_blob_list_callbacks cbs = { - .begin_blob = write_blob_begin_read, - .begin_blob_ctx = &ctx, - .consume_chunk = write_blob_process_chunk, - .consume_chunk_ctx = &ctx, - .end_blob = write_blob_end_read, - .end_blob_ctx = &ctx, + struct read_blob_callbacks cbs = { + .begin_blob = write_blob_begin_read, + .consume_chunk = write_blob_process_chunk, + .end_blob = write_blob_end_read, + .ctx = &ctx, }; ret = read_blob_list(blob_list,