Author: paperwing
Date: 2012-08-29 14:54:33 -0700 (Wed, 29 Aug 2012)
New Revision: 30290

Modified:
   
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/net/WebQuerier.java
Log:
fixes #1410 No longer only downloads first 16 megabytes of app file, downloads 
entire app file

Modified: 
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/net/WebQuerier.java
===================================================================
--- 
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/net/WebQuerier.java
      2012-08-29 19:33:05 UTC (rev 30289)
+++ 
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/net/WebQuerier.java
      2012-08-29 21:54:33 UTC (rev 30290)
@@ -8,6 +8,7 @@
 import java.net.MalformedURLException;
 import java.net.URL;
 import java.nio.channels.Channels;
+import java.nio.channels.FileChannel;
 import java.nio.channels.ReadableByteChannel;
 import java.util.Collections;
 import java.util.Comparator;
@@ -504,8 +505,29 @@
                                        outputFile.createNewFile();
                                        
                                    FileOutputStream fileOutputStream = new 
FileOutputStream(outputFile);
-                                   
fileOutputStream.getChannel().transferFrom(readableByteChannel, 0, 1 << 24);
+                                   FileChannel fileChannel = 
fileOutputStream.getChannel();
                                    
+                                   long currentDownloadPosition = 0;
+                                   long bytesTransferred;
+                                   
+                                   do {
+                                       bytesTransferred = 
fileChannel.transferFrom(readableByteChannel, currentDownloadPosition, 1 << 20);
+//                                     System.out.println("Position: " + 
currentDownloadPosition + " new bytes: " + bytesTransferred);
+                                       currentDownloadPosition += 
bytesTransferred;
+                                   } while (bytesTransferred > 0);
+                                   
+//                                 System.out.println("outfile: " + 
outputFile.getAbsolutePath());
+                                   
+                                   try {
+                                       fileOutputStream.close();
+                                   } catch (IOException e) {
+                                   }
+                                   
+                                   try {
+                                       readableByteChannel.close();
+                                   } catch (IOException e) {
+                                   }
+                                   
                                    return outputFile;
                                } catch (IOException e) {
                                        throw new AppDownloadException("Error 
while downloading app " + webApp.getFullName()

-- 
You received this message because you are subscribed to the Google Groups 
"cytoscape-cvs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/cytoscape-cvs?hl=en.

Reply via email to