postprocess: Minor glnx_console interaction fixes

Make sure we always pass an integer and not a float to
`glnx_console_progress_text_percent`. And also make sure we clamp the
value we pass to 100. Not sure how I hit this, somehow the byte counting
we do upfront before committing is *less* than the addition of all the
`g_file_info_get_size()`s?

Closes: #1658
Approved by: cgwalters
This commit is contained in:
Jonathan Lebon 2018-11-02 13:26:29 -04:00 committed by Atomic Bot
parent a2d67f658a
commit c3be38af72

View File

@ -2018,7 +2018,8 @@ on_progress_timeout (gpointer datap)
struct CommitThreadData *data = datap; struct CommitThreadData *data = datap;
const gint percent = g_atomic_int_get (&data->percent); const gint percent = g_atomic_int_get (&data->percent);
glnx_console_progress_text_percent ("Committing:", percent); /* clamp to 100 if it somehow goes over (XXX: bad counting?) */
glnx_console_progress_text_percent ("Committing:", MIN(percent, 100));
return TRUE; return TRUE;
} }
@ -2100,7 +2101,7 @@ rpmostree_compose_commit (int rootfs_fd,
while (g_atomic_int_get (&tdata.done) == 0) while (g_atomic_int_get (&tdata.done) == 0)
g_main_context_iteration (NULL, TRUE); g_main_context_iteration (NULL, TRUE);
glnx_console_progress_text_percent ("Committing:", 100.0); glnx_console_progress_text_percent ("Committing:", 100);
glnx_console_unlock (&console); glnx_console_unlock (&console);
g_thread_join (g_steal_pointer (&commit_thread)); g_thread_join (g_steal_pointer (&commit_thread));