Skip to content

Commit

Permalink
src: drop individual progress update skipping
Browse files Browse the repository at this point in the history
The r_context_set_step_percentage() itself now prevents emitting
progress when nothing changed actually.
So no need to have this behavior individually on each call.

Signed-off-by: Enrico Jörns <[email protected]>
  • Loading branch information
ejoerns committed Feb 10, 2025
1 parent 927d9c6 commit f20a2ad
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 21 deletions.
18 changes: 4 additions & 14 deletions src/update_handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,6 @@ static gboolean splice_with_progress(GUnixInputStream *image_stream,
struct stat stat = {};
ssize_t out_size = 0;
goffset sum_size = 0;
gint last_percent = -1, percent;

if (fstat(in_fd, &stat)) {
int err = errno;
Expand All @@ -212,12 +211,8 @@ static gboolean splice_with_progress(GUnixInputStream *image_stream,

sum_size += out_size;

percent = sum_size * 100 / stat.st_size;
/* emit progress info (but only when in progress context) */
if (r_context()->progress && percent != last_percent) {
last_percent = percent;
r_context_set_step_percentage("copy_image", percent);
}
/* emit progress info */
r_context_set_step_percentage("copy_image", sum_size * 100 / stat.st_size);
} while (out_size);

return TRUE;
Expand Down Expand Up @@ -694,7 +689,6 @@ static gboolean copy_block_hash_index_image_to_dev(RaucImage *image, RaucSlot *s
off_t offset = 0;
int target_fd = -1;
g_autoptr(RaucStats) zero_stats = NULL;
gint last_percent = -1, percent;

g_return_val_if_fail(image, FALSE);
g_return_val_if_fail(slot, FALSE);
Expand Down Expand Up @@ -847,12 +841,8 @@ static gboolean copy_block_hash_index_image_to_dev(RaucImage *image, RaucSlot *s
target_old->invalid_below = c;
}

percent = (c + 1) * 100 / chunk_count;
/* emit progress info (but only when in progress context) */
if (r_context()->progress && percent != last_percent) {
last_percent = percent;
r_context_set_step_percentage("copy_image", percent);
}
/* emit progress info */
r_context_set_step_percentage("copy_image", (c + 1) * 100 / chunk_count);
}

/* Seek after the written data so this behaves similar to the simpler write helpers */
Expand Down
9 changes: 2 additions & 7 deletions src/update_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ gboolean r_copy_stream_with_progress(GInputStream *in_stream, GOutputStream *out
GError *ierror = NULL;
gsize out_size = 0;
goffset sum_size = 0;
gint last_percent = -1, percent;
gchar buffer[8192];
gssize in_size;

Expand Down Expand Up @@ -122,12 +121,8 @@ gboolean r_copy_stream_with_progress(GInputStream *in_stream, GOutputStream *out

sum_size += out_size;

percent = sum_size * 100 / size;
/* emit progress info (but only when in progress context) */
if (r_context()->progress && percent != last_percent) {
last_percent = percent;
r_context_set_step_percentage("copy_image", percent);
}
/* emit progress info */
r_context_set_step_percentage("copy_image", sum_size * 100 / size);
} while (out_size);

return TRUE;
Expand Down

0 comments on commit f20a2ad

Please sign in to comment.