Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 18 additions & 24 deletions qubes-rpc/qvm-copy-to-vm.gnome
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ set_qdbus() {
}

copy() {
PROGRESS_TYPE=gui /usr/lib/qubes/qrexec-client-vm @default \
qubes.Filecopy /usr/lib/qubes/qfile-agent "$@"
PROGRESS_TYPE=gui /usr/lib/qubes/qrexec-client-vm \
--filter-escape-chars-stderr -- @default \
"$service" /usr/lib/qubes/qfile-agent "$@"
}

progress_kdialog() {
Expand All @@ -43,11 +44,11 @@ progress_kdialog() {
(while read -r pos; do
if [[ $pos == 0 ]]; then
# shellcheck disable=SC2207
ref=( $(kdialog --progressbar "$DESCRIPTION") )
ref=( $(kdialog --progressbar "$description") )
trap '"$qdbus" "${ref[@]}" close' EXIT # for this subshell
fi

"$qdbus" "${ref[@]}" value $((100 * pos / SIZE))
"$qdbus" "${ref[@]}" value $((100 * pos / size))
done) >/dev/null # hide qdbus's empty output lines
}

Expand All @@ -57,38 +58,31 @@ progress_zenity() {
(while read -r pos; do
if [[ $pos == 0 ]]; then
trap 'kill -- $!' EXIT # for this subshell
exec {fd}> >(exec zenity --progress --text="$DESCRIPTION")
exec {fd}> >(exec zenity --progress --text="$description")
fi

echo $((100 * pos / SIZE)) >&$fd
echo $((100 * pos / size)) >&$fd
done)
}


find_paths=( )
for path; do
case "$path" in
(-*) find_paths+=( ./"$path" ) ;;
(*) find_paths+=( "$path" ) ;;
esac
done

SIZE=$(
find "${find_paths[@]}" -type f -print0 2>/dev/null |
du --files0-from - -c --apparent-size -b |
tail -n 1 |
cut -f 1 |
grep -xE '[0-9]+'
) || SIZE=0
if size=$(/usr/lib/qubes/qubes-fs-tree-check \
--allow-symlinks --allow-directories --machine -- "$@"); then
service=qubes.Filecopy
else
status=$?
if [[ "$status" -ne 2 ]]; then exit "$status"; fi
service=qubes.Filecopy+allow-all-names
fi

if [[ ${0##*/} == qvm-move-to-vm.* ]]; then
DESCRIPTION="Moving files..."
description="Moving files..."
trap '[[ $? == 0 ]] && rm -rf -- "$@"' EXIT
else
DESCRIPTION="Copying files..."
description="Copying files..."
fi

if [[ $SIZE == 0 ]]; then
if [[ $size == 0 ]]; then
copy "$@" >/dev/null
elif [[ $0 == *.kde ]] && type kdialog >/dev/null && set_qdbus; then
copy "$@" | progress_kdialog
Expand Down