1 Reply Latest reply: Jul 17, 2014 7:05 AM by Frank Caggiano
Matteo_999 Level 1 (0 points)



I'm trying to add on my app a progress bar that increases depending on the progress of rsync synchronization.

Is there a way to do that without ASObjC Runner and other stuff lime this, but do the whole thing in x-code?

I also know that in rsync the flag --progress shows the percentage progress of the synchronization, maybe it can be done reading the value of the progress.

I hope someone can answer.


Thanks in advance!

  • Frank Caggiano Level 7 (25,722 points)

    Progress bar's aren't intelligent things that somehow keep track of the progress of an operation on their own. You as the programmer need to know where you are in the operation and undate the progress bar to reflect this. So this means you need to know just how much of the operation has taken place at any given point in time.


    If you start up an rsync process from your application there is no way to know how much progress has taken place, just as if you started up rsync from the terminal. Rsync does it's thing and  you want for the terminal prompt to come back to know it is done. 


    So in this case there is no way to meaningfully update a progress bar.


    However there is that --progress argument to rsync that does print out something on the terminal which sort of informs the user as to what is going on. If you read the explanation of the progress argument you'll see that  rsync might not know just how much progress it has made, it's a bit of a guess for it also.


    Now if you really wanted to you could capture rsync's output in your program parse the line it is printing and use that information to update a progress bar but to be honest this is a lot more work then, for me at least, it is worth.


    Operations like this are usually best indicted by using the indeterminate progress indicator,


    Screen Shot 2014-07-17 at 10.02.34 .png

    You let the user know something is going on but you don;t rally know how long the operation will take.