[banshee] [Dap.AppleDevice] Fix the total in the progress while sync occurs



commit 5efc045b23949c7b5b7b8ac3e22ae80dbc212c82
Author: Andrés G. Aragoneses <knocte gmail com>
Date:   Sun Sep 19 13:48:06 2010 +0200

    [Dap.AppleDevice] Fix the total in the progress while sync occurs
    
    It may happen that tracks_to_add gets more songs in the middle
    of a sync so we calculate the total now inside of a lock{} and
    on every iteration.
    
    This was brought up by Gabriel Burt in a review of a patch for
    BGO#620826.
    
    Signed-off by: Alan McGovern <alan mcgovern gmail com>

 .../Banshee.Dap.AppleDevice/AppleDeviceSource.cs   |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
---
diff --git a/src/Dap/Banshee.Dap.AppleDevice/Banshee.Dap.AppleDevice/AppleDeviceSource.cs b/src/Dap/Banshee.Dap.AppleDevice/Banshee.Dap.AppleDevice/AppleDeviceSource.cs
index 077a0dd..815d340 100644
--- a/src/Dap/Banshee.Dap.AppleDevice/Banshee.Dap.AppleDevice/AppleDeviceSource.cs
+++ b/src/Dap/Banshee.Dap.AppleDevice/Banshee.Dap.AppleDevice/AppleDeviceSource.cs
@@ -492,7 +492,7 @@ namespace Banshee.Dap.AppleDevice
             Hyena.Log.Debug ("Starting AppleDevice sync thread cycle");
 
             string message;
-            int total;
+            int total, i = 0;
             var progressUpdater = new UserJob (Catalog.GetString ("Syncing iPod"),
                                                Catalog.GetString ("Preparing to synchronize..."), GetIconNames ());
             progressUpdater.Register ();
@@ -502,11 +502,12 @@ namespace Banshee.Dap.AppleDevice
             while (tracks_to_add.Count > 0) {
                 AppleDeviceTrackInfo track = null;
                 lock (sync_mutex) {
+                    total = tracks_to_add.Count + i;
                     track = tracks_to_add.Dequeue ();
                 }
 
                 try {
-                    UpdateProgress (progressUpdater, message, total - tracks_to_add.Count, total);
+                    UpdateProgress (progressUpdater, message, ++i, total);
                     track.CommitToIpod (MediaDatabase);
                     track.Save (false);
                     tracks_map[track.TrackId] = track;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]