I haven't tested everything completely yet, but I believe I've fixed most of the problems associated with resuming downloads. Below is a patch for the source release currently available at
http://download.limewire.org/servlet...wnload&dlID=15.
Code:
diff -br -C 2 core/com/limegroup/gnutella/DownloadManager.java ../limewire_new/core/com/limegroup/gnutella/DownloadManager.java
*** core/com/limegroup/gnutella/DownloadManager.java Thu Dec 13 18:27:02 2001
--- ../limewire_new/core/com/limegroup/gnutella/DownloadManager.java Fri Mar 1 19:20:14 2002
***************
*** 433,436 ****
--- 433,446 ----
}
+ /** Stops all downloads, then readds them to the waiting list. */
+ public synchronized void stopAllDownloads() {
+ for (Iterator iter=active.iterator(); iter.hasNext(); ) {
+ ManagedDownloader md=(ManagedDownloader)iter.next();
+ ManagedDownloader dupe=new ManagedDownloader(
+ this, md.getFiles(), fileManager, incompleteFileManager);
+ waiting.add(dupe);
+ md.stop();
+ }
+ }
/** Calls measureBandwidth on each uploader. */
diff -br -C 2 core/com/limegroup/gnutella/RouterService.java ../limewire_new/core/com/limegroup/gnutella/RouterService.java
*** core/com/limegroup/gnutella/RouterService.java Thu Dec 6 14:59:06 2001
--- ../limewire_new/core/com/limegroup/gnutella/RouterService.java Fri Mar 1 19:09:22 2002
***************
*** 350,353 ****
--- 350,356 ----
*/
public void shutdown() {
+ //Stop all downloads to make sure we remember them
+ downloader.stopAllDownloads();
+
//Write gnutella.net
try {
diff -br -C 2 core/com/limegroup/gnutella/downloader/IncompleteFileManager.java ../limewire_new/core/com/limegroup/gnutella/downloader/IncompleteFileManager.java
*** core/com/limegroup/gnutella/downloader/IncompleteFileManager.java Thu Dec 13 18:27:02 2001
--- ../limewire_new/core/com/limegroup/gnutella/downloader/IncompleteFileManager.java Fri Mar 1 19:24:24 2002
***************
*** 48,52 ****
for (Iterator iter=blocks.keySet().iterator(); iter.hasNext(); ) {
File file=(File)iter.next();
! if (!file.exists() || isOld(file)) {
ret=true;
file.delete(); //always safe to call; return value ignored
--- 48,52 ----
for (Iterator iter=blocks.keySet().iterator(); iter.hasNext(); ) {
File file=(File)iter.next();
! if (!file.exists()) {
ret=true;
file.delete(); //always safe to call; return value ignored
diff -br -C 2 core/com/limegroup/gnutella/downloader/ManagedDownloader.java ../limewire_new/core/com/limegroup/gnutella/downloader/ManagedDownloader.java
*** core/com/limegroup/gnutella/downloader/ManagedDownloader.java Tue Dec 18 11:35:40 2001
--- ../limewire_new/core/com/limegroup/gnutella/downloader/ManagedDownloader.java Fri Mar 1 19:23:38 2002
***************
*** 1070,1073 ****
--- 1070,1077 ----
*************************************************************************/
+ public synchronized RemoteFileDesc[] getFiles() {
+ return allFiles;
+ }
+
public synchronized int getState() {
return state;