Skip to content

Commit ca6e96d

Browse files
committed
qfile-agent: fix CLI progress display unit mismatch
qubes-fs-tree-check outputs the total estimated size in bytes, not KB. Fix the display bug by renaming the env variable that's used to pass this number (in the qvm-copy wrapper script) to $FILECOPY_TOTAL_BYTES, and then making qfile-agent convert from bytes to KB display units. $ truncate -s 10K foo $ qvm-copy foo # before: sent 10/10240 KB $ qvm-copy foo # after: sent 10/10 KB
1 parent 2b7b10a commit ca6e96d

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

qubes-rpc/qfile-agent.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,17 @@ enum {
2121

2222
void do_notify_progress(long long cur_total, int flag)
2323
{
24-
const char *du_size_env = getenv("FILECOPY_TOTAL_SIZE");
24+
const char *total_bytes_env = getenv("FILECOPY_TOTAL_BYTES");
2525
const char *progress_type_env = getenv("PROGRESS_TYPE");
2626
const char *saved_stdout_env = getenv("SAVED_FD_1");
2727
int ignore;
2828
if (!progress_type_env)
2929
return;
30-
if (!strcmp(progress_type_env, "console") && du_size_env) {
30+
if (!strcmp(progress_type_env, "console") && total_bytes_env) {
3131
char msg[256];
3232
snprintf(msg, sizeof(msg), "sent %lld/%lld KB\r",
33-
(cur_total + 1023) / 1024, strtoull(du_size_env, NULL, 10));
33+
(cur_total + 1023) / 1024,
34+
(strtoull(total_bytes_env, NULL, 10) + 1023) / 1024);
3435
ignore = write(2, msg, strlen(msg));
3536
if (flag == PROGRESS_FLAG_DONE)
3637
ignore = write(2, "\n", 1);

qubes-rpc/qvm-copy

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
set -e -o pipefail
2323

24-
unset PROGRESS_TYPE OPERATION_TYPE TARGET_TYPE MIN_ARGS FILECOPY_TOTAL_SIZE service scriptdir
24+
unset PROGRESS_TYPE OPERATION_TYPE TARGET_TYPE MIN_ARGS FILECOPY_TOTAL_BYTES service scriptdir
2525

2626
# Determine the operation to be performed
2727
case ${0##*/} in
@@ -82,15 +82,15 @@ else
8282
VM="@default"
8383
fi
8484

85-
if FILECOPY_TOTAL_SIZE=$("$scriptdir/qubes/qubes-fs-tree-check" \
85+
if FILECOPY_TOTAL_BYTES=$("$scriptdir/qubes/qubes-fs-tree-check" \
8686
--allow-symlinks --allow-directories --machine -- "$@"); then
8787
service=qubes.Filecopy
8888
else
8989
status=$?
9090
if [[ "$status" -ne 2 ]]; then exit "$status"; fi
9191
service=qubes.Filecopy+allow-all-names
9292
fi
93-
if [[ "$PROGRESS_TYPE" = 'console' ]]; then export FILECOPY_TOTAL_SIZE; fi
93+
if [[ "$PROGRESS_TYPE" = 'console' ]]; then export FILECOPY_TOTAL_BYTES; fi
9494

9595
"$scriptdir/qubes/qrexec-client-vm" --filter-escape-chars-stderr -- "$VM" \
9696
"$service" "$scriptdir/qubes/qfile-agent" "$@"

0 commit comments

Comments
 (0)