Skip to content

Commit d9b5dfb

Browse files
committed
Improve progress bar a bit
1 parent 40aa797 commit d9b5dfb

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

AppImageUpdate.AppDir/usr/bin/appimageupdate

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ set -e
55
# This script is supposed to be run either on the command line
66
# or though the appimageupdate GUI. The GUI is purely optional.
77
# It displays stdout and stderr, as well as a progress indicator.
8+
# Communication between this script and the GUI happen through
9+
# file descriptors (&1 = stdout, &2 = stderr, $3 ... up to &9)
10+
# http://stackoverflow.com/questions/2342826/how-to-pipe-stderr-and-not-stdout
11+
#
12+
# echo "######" | tee >(sed -e 's/#/#\n/g' >&1)
813

914
error()
1015
{
@@ -129,7 +134,7 @@ if [ "$TYPE" == "zsync" ] ; then
129134
# .part appended, so it will automatically find previously interrupted zsync
130135
# downloads and reuse the data already downloaded.
131136
ZSYNC_URL=$(echo "${APPLICATION_USED}" | cut -d "|" -f 2) # Get the URL of the zsync file
132-
zsync_curl -# -I -i "${ISO}" "${ZSYNC_URL}" # Get the file with zsync using $1 as an input file
137+
zsync_curl -# -I -i "${ISO}" "${ZSYNC_URL}" 2>&1 | tee >(sed -e 's/#/#\n/g') # Get the file with zsync using $1 as an input file
133138
NEWFILE=$(basename "${ZSYNC_URL}" | sed -e 's|.zsync||g' ) # FIXME: Use the file that zsync has written!!!
134139
chmod --reference="${ISO}" "${NEWFILE}"* # Set the same permissions as for the original file
135140
gpg_check
@@ -158,7 +163,7 @@ elif [ "$TYPE" == "bintray-zsync" ] ; then
158163
echo "Latest version: ${VERSION}"
159164
fi
160165
ZSYNC_URL=$(echo "${DUMMY_URL}" | sed -e "s|_latestVersion|$VERSION|g" )
161-
zsync_curl -I -i "${ISO}" "${ZSYNC_URL}" # Get the file with zsync using $1 as an input file
166+
zsync_curl -I -i "${ISO}" "${ZSYNC_URL}" 2>&1 | tee >(sed -e 's/#/#\n/g') # Get the file with zsync using $1 as an input file
162167
NEWFILE=$(basename "${ZSYNC_URL}" | sed -e 's|.zsync||g' ) # FIXME: Use the file that zsync has written!!!
163168
chmod --reference="${ISO}" "${NEWFILE}"* # Set the same permissions as for the original file
164169
gpg_check

appimageupdategui/progress.vala

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
using Gtk;
22

3+
// http://stackoverflow.com/questions/20846511/read-write-file-pipes-in-vala-glib
4+
// http://www.valadoc.org/#!api=glib-2.0/GLib.IOChannel.IOChannel.unix_new
5+
// http://www.valadoc.org/#!api=glib-2.0/GLib.IOChannel
6+
37
public class ProgressWindow : Window {
48

59
private string file_name;
@@ -129,7 +133,7 @@ public class ProgressWindow : Window {
129133
string line;
130134
channel.read_line (out line, null, null);
131135
stdout.printf(line); // Be verbose
132-
file_counts = 12; // TODO: Get from command line output
136+
file_counts = 30; // TODO: Get from command line output
133137
action_label.label = line.substring(0, line.length - 1);
134138
counter++;
135139
progress.set_fraction( 1.0f * counter / file_counts);

0 commit comments

Comments
 (0)