Author: alanmc
Date: 2007-03-23 10:19:01 -0500 (Fri, 23 Mar 2007)
New Revision: 74879

Modified:
   trunk/bitsharp/src/MonoTorrent.Client/ClientEngine.cs
   trunk/bitsharp/src/MonoTorrent.Client/Managers/TorrentManager.cs
Log:
Now firing PieceHashed event on torrentManger.Start() if fast resume data was 
loaded

Modified: trunk/bitsharp/src/MonoTorrent.Client/ClientEngine.cs
===================================================================
--- trunk/bitsharp/src/MonoTorrent.Client/ClientEngine.cs       2007-03-23 
15:08:54 UTC (rev 74878)
+++ trunk/bitsharp/src/MonoTorrent.Client/ClientEngine.cs       2007-03-23 
15:19:01 UTC (rev 74879)
@@ -421,6 +421,7 @@
                 using (FileStream file = 
File.OpenRead(manager.Torrent.TorrentPath + ".fresume"))
                     
manager.PieceManager.MyBitField.FromArray((int[])fastResume.Deserialize(file), 
manager.Torrent.Pieces.Count);
 
+                manager.loadedFastResume = true;
                 return true;
             }
             catch

Modified: trunk/bitsharp/src/MonoTorrent.Client/Managers/TorrentManager.cs
===================================================================
--- trunk/bitsharp/src/MonoTorrent.Client/Managers/TorrentManager.cs    
2007-03-23 15:08:54 UTC (rev 74878)
+++ trunk/bitsharp/src/MonoTorrent.Client/Managers/TorrentManager.cs    
2007-03-23 15:19:01 UTC (rev 74879)
@@ -67,6 +67,7 @@
         public event EventHandler<TorrentStateChangedEventArgs> 
TorrentStateChanged;
         #endregion
 
+        internal bool loadedFastResume;
 
         #region Member Variables
         public ConnectionMonitor Monitor
@@ -279,6 +280,15 @@
             if (this.state == TorrentState.Seeding || this.state == 
TorrentState.SuperSeeding || this.state == TorrentState.Downloading)
                 throw new TorrentException("Torrent is already running");
 
+            if (this.loadedFastResume)
+            {
+                for (int i = 0; i < this.bitfield.Length; i++)
+                    if (PieceHashed != null)
+                        PieceHashed(this, new PieceHashedEventArgs(i, 
this.bitfield[i]));
+
+                this.loadedFastResume = false;
+            }
+
             if (this.Progress == 100.0)
                 UpdateState(TorrentState.Seeding);
             else

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to