Author: jflesch
Date: 2007-06-23 15:51:16 +0000 (Sat, 23 Jun 2007)
New Revision: 13733

Modified:
   trunk/apps/Thaw/src/thaw/fcp/FCPClientGet.java
   trunk/apps/Thaw/src/thaw/fcp/FCPConnection.java
Log:
Try to fix the behavior of FCPClientGet when disconnected when downloading data 
from the node

Modified: trunk/apps/Thaw/src/thaw/fcp/FCPClientGet.java
===================================================================
--- trunk/apps/Thaw/src/thaw/fcp/FCPClientGet.java      2007-06-23 14:34:49 UTC 
(rev 13732)
+++ trunk/apps/Thaw/src/thaw/fcp/FCPClientGet.java      2007-06-23 15:51:16 UTC 
(rev 13733)
@@ -505,11 +505,15 @@

                        if(fetchDirectly(queryManager.getConnection(), 
fileSize, true)) {
                                writingSuccessful = true;
+                               successful = false;
                                status = "Available";
                        } else {
                                Logger.warning(this, "Unable to fetch correctly 
the file. This may create problems on socket");
-                               writingSuccessful = false;
-                               status = "Error while receveing the file";
+                               if (writingSuccessful) { /* if we forgot to set 
the correct values */
+                                       writingSuccessful = false;
+                                       successful = false;
+                                       status = "Error while receveing the 
file";
+                               }
                        }

                        Logger.info(this, "File received");
@@ -717,9 +721,17 @@

                        if(amount <= -1) {
                                Logger.error(this, "Socket closed, damn !");
-                               status = "Read error";
+                               status = "Unable to read data from the node";
                                writingSuccessful = false;
-                               break;
+                               successful = false;
+                               try {
+                                       outputStream.close();
+                               } catch(java.io.IOException ex) {
+                                       Logger.error(this, "Unable to close the 
file cleanly : "+ex.toString());
+                                       Logger.error(this, "Things seem to go 
wrong !");
+                               }
+                               newFile.delete();
+                               return false;
                        }

                        if(reallyWrite) {
@@ -729,6 +741,14 @@
                                        Logger.error(this, "Unable to write 
file on disk ... out of space ? : "+e.toString());
                                        status = "Unable to fetch / disk 
probably full !";
                                        writingSuccessful = false;
+                                       successful = false;
+                                       try {
+                                               outputStream.close();
+                                       } catch(java.io.IOException ex) {
+                                               Logger.error(this, "Unable to 
close the file cleanly : "+ex.toString());
+                                               Logger.error(this, "Things seem 
to go wrong !");
+                                       }
+                                       newFile.delete();
                                        return false;
                                }
                        }

Modified: trunk/apps/Thaw/src/thaw/fcp/FCPConnection.java
===================================================================
--- trunk/apps/Thaw/src/thaw/fcp/FCPConnection.java     2007-06-23 14:34:49 UTC 
(rev 13732)
+++ trunk/apps/Thaw/src/thaw/fcp/FCPConnection.java     2007-06-23 15:51:16 UTC 
(rev 13733)
@@ -334,6 +334,7 @@
                        if(rdBytes < 0) {
                                Logger.error(this, "Error while reading on the 
socket => disconnection");
                                disconnect();
+                               return rdBytes;
                        }

                        rawBytesWaiting = rawBytesWaiting - rdBytes;


Reply via email to