]> wimlib.net Git - wimlib/blobdiff - src/write.c
Remove broken completed_parts write progress
[wimlib] / src / write.c
index b8d86e85fc7bf6540630ac8f0f1d950b64c226c9..292aa7d129ec500ad95494384f7f6325d93a7e9a 100644 (file)
@@ -39,6 +39,7 @@
 #include "wimlib/error.h"
 #include "wimlib/file_io.h"
 #include "wimlib/header.h"
+#include "wimlib/inode.h"
 #include "wimlib/integrity.h"
 #include "wimlib/lookup_table.h"
 #include "wimlib/metadata.h"
@@ -277,7 +278,6 @@ struct write_streams_progress_data {
        wimlib_progress_func_t progress_func;
        union wimlib_progress_info progress;
        uint64_t next_progress;
-       WIMStruct *prev_wim_part;
 };
 
 static void
@@ -288,7 +288,6 @@ do_write_streams_progress(struct write_streams_progress_data *progress_data,
                          bool discarded)
 {
        union wimlib_progress_info *progress = &progress_data->progress;
-       bool new_wim_part;
 
        if (discarded) {
                progress->write_streams.total_bytes -= complete_size;
@@ -303,20 +302,8 @@ do_write_streams_progress(struct write_streams_progress_data *progress_data,
                progress->write_streams.completed_streams += complete_count;
        }
 
-       new_wim_part = false;
-       if (cur_stream->resource_location == RESOURCE_IN_WIM &&
-           cur_stream->rspec->wim != progress_data->prev_wim_part)
-       {
-               if (progress_data->prev_wim_part) {
-                       new_wim_part = true;
-                       progress->write_streams.completed_parts++;
-               }
-               progress_data->prev_wim_part = cur_stream->rspec->wim;
-       }
-
        if (progress_data->progress_func
-           && (progress->write_streams.completed_bytes >= progress_data->next_progress
-               || new_wim_part))
+           && (progress->write_streams.completed_bytes >= progress_data->next_progress))
        {
                progress_data->progress_func(WIMLIB_PROGRESS_MSG_WRITE_STREAMS,
                                             progress);
@@ -568,8 +555,8 @@ end_chunk_table(struct write_streams_ctx *ctx, u64 res_actual_size,
                        hdr.chunk_size = cpu_to_le32(ctx->out_chunk_size);
                        hdr.compression_format = cpu_to_le32(ctx->out_ctype);
 
-                       BUILD_BUG_ON(WIMLIB_COMPRESSION_TYPE_LZX != 1);
-                       BUILD_BUG_ON(WIMLIB_COMPRESSION_TYPE_XPRESS != 2);
+                       BUILD_BUG_ON(WIMLIB_COMPRESSION_TYPE_XPRESS != 1);
+                       BUILD_BUG_ON(WIMLIB_COMPRESSION_TYPE_LZX != 2);
                        BUILD_BUG_ON(WIMLIB_COMPRESSION_TYPE_LZMS != 3);
 
                        ret = full_pwrite(ctx->out_fd, &hdr, sizeof(hdr),
@@ -1060,7 +1047,6 @@ compute_stream_list_stats(struct list_head *stream_list,
        ctx->progress_data.progress.write_streams.total_parts       = total_parts;
        ctx->progress_data.progress.write_streams.completed_parts   = 0;
        ctx->progress_data.next_progress = 0;
-       ctx->progress_data.prev_wim_part = NULL;
 }
 
 /* Find streams in @stream_list that can be copied to the output WIM in raw form
@@ -1429,11 +1415,11 @@ write_stream_list(struct list_head *stream_list,
         * to do compression.  There are serial and parallel implementations of
         * the chunk_compressor interface.  We default to parallel using the
         * specified number of threads, unless the upper bound on the number
-        * bytes needing to be compressed is less 2000000 (heuristic value).  */
+        * bytes needing to be compressed is less than a heuristic value.  */
        if (out_ctype != WIMLIB_COMPRESSION_TYPE_NONE) {
 
        #ifdef ENABLE_MULTITHREADED_COMPRESSION
-               if (ctx.num_bytes_to_compress >= 2000000) {
+               if (ctx.num_bytes_to_compress > max(2000000, out_chunk_size)) {
                        ret = new_parallel_chunk_compressor(out_ctype,
                                                            out_chunk_size,
                                                            num_threads, 0,
@@ -1842,7 +1828,7 @@ determine_stream_size_uniquity(struct list_head *stream_list,
        struct stream_size_table tab;
        struct wim_lookup_table_entry *lte;
 
-       ret = init_stream_size_table(&tab, lt->capacity);
+       ret = init_stream_size_table(&tab, 9001);
        if (ret)
                return ret;
 
@@ -2818,10 +2804,11 @@ wimlib_write(WIMStruct *wim, const tchar *path,
             int image, int write_flags, unsigned num_threads,
             wimlib_progress_func_t progress_func)
 {
-       if (!path)
+       if (write_flags & ~WIMLIB_WRITE_MASK_PUBLIC)
                return WIMLIB_ERR_INVALID_PARAM;
 
-       write_flags &= WIMLIB_WRITE_MASK_PUBLIC;
+       if (path == NULL || path[0] == T('\0'))
+               return WIMLIB_ERR_INVALID_PARAM;
 
        return write_standalone_wim(wim, path, image, write_flags,
                                    num_threads, progress_func);
@@ -2833,10 +2820,12 @@ wimlib_write_to_fd(WIMStruct *wim, int fd,
                   int image, int write_flags, unsigned num_threads,
                   wimlib_progress_func_t progress_func)
 {
+       if (write_flags & ~WIMLIB_WRITE_MASK_PUBLIC)
+               return WIMLIB_ERR_INVALID_PARAM;
+
        if (fd < 0)
                return WIMLIB_ERR_INVALID_PARAM;
 
-       write_flags &= WIMLIB_WRITE_MASK_PUBLIC;
        write_flags |= WIMLIB_WRITE_FLAG_FILE_DESCRIPTOR;
 
        return write_standalone_wim(wim, &fd, image, write_flags,
@@ -3122,7 +3111,10 @@ overwrite_wim_via_tmpfile(WIMStruct *wim, int write_flags,
                return ret;
        }
 
-       close_wim(wim);
+       if (filedes_valid(&wim->in_fd)) {
+               filedes_close(&wim->in_fd);
+               filedes_invalidate(&wim->in_fd);
+       }
 
        /* Rename the new WIM file to the original WIM file.  Note: on Windows
         * this actually calls win32_rename_replacement(), not _wrename(), so
@@ -3196,9 +3188,7 @@ wimlib_overwrite(WIMStruct *wim, int write_flags,
        int ret;
        u32 orig_hdr_flags;
 
-       write_flags &= WIMLIB_WRITE_MASK_PUBLIC;
-
-       if (write_flags & WIMLIB_WRITE_FLAG_FILE_DESCRIPTOR)
+       if (write_flags & ~WIMLIB_WRITE_MASK_PUBLIC)
                return WIMLIB_ERR_INVALID_PARAM;
 
        if (!wim->filename)