summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Rettberg2023-07-10 14:51:33 +0200
committerSimon Rettberg2023-07-10 14:51:33 +0200
commitd603f91ff3c484719d2adbb81a29b8eb4fa4c12e (patch)
treeaf31f7680eadd9b435d0fa088457f1fb5d197697
parent[filetransfer] Improve error logging (diff)
downloadmaster-sync-shared-d603f91ff3c484719d2adbb81a29b8eb4fa4c12e.tar.gz
master-sync-shared-d603f91ff3c484719d2adbb81a29b8eb4fa4c12e.tar.xz
master-sync-shared-d603f91ff3c484719d2adbb81a29b8eb4fa4c12e.zip
[filetransfer] Also check meta data error string in Up-/Download loop
-rw-r--r--src/main/java/org/openslx/filetransfer/Downloader.java4
-rw-r--r--src/main/java/org/openslx/filetransfer/Transfer.java11
-rw-r--r--src/main/java/org/openslx/filetransfer/Uploader.java4
3 files changed, 14 insertions, 5 deletions
diff --git a/src/main/java/org/openslx/filetransfer/Downloader.java b/src/main/java/org/openslx/filetransfer/Downloader.java
index c79810d..495a096 100644
--- a/src/main/java/org/openslx/filetransfer/Downloader.java
+++ b/src/main/java/org/openslx/filetransfer/Downloader.java
@@ -202,6 +202,10 @@ public class Downloader extends Transfer
log.error( "Did not receive meta data from uploading remote peer after requesting range, aborting." );
return false;
}
+ if ( getRemoteError() != null ) {
+ log.error( "Remote peer sent error: " + getRemoteError() );
+ return false;
+ }
FileRange remoteRange = meta.getRange();
if ( remoteRange == null ) {
log.error( "Remote metadata does not contain range confirmation. " + meta );
diff --git a/src/main/java/org/openslx/filetransfer/Transfer.java b/src/main/java/org/openslx/filetransfer/Transfer.java
index 4b15e60..cf4c6d3 100644
--- a/src/main/java/org/openslx/filetransfer/Transfer.java
+++ b/src/main/java/org/openslx/filetransfer/Transfer.java
@@ -24,7 +24,7 @@ public abstract class Transfer
protected final Socket transferSocket;
protected final DataOutputStream outStream;
protected final DataInputStream dataFromServer;
- protected String ERROR = null;
+ private String remoteError;
private boolean shouldGetToken;
protected boolean useCompression = true;
@@ -170,6 +170,7 @@ public abstract class Transfer
*/
protected MetaData readMetaData()
{
+
Map<String, String> entries = new HashMap<>();
try {
while ( true ) {
@@ -184,7 +185,7 @@ public abstract class Transfer
continue;
}
if ( splitted[0].equals( "ERROR" ) )
- ERROR = splitted[1];
+ remoteError = splitted[1];
if ( entries.containsKey( splitted[0] ) ) {
log.warn( "Received meta data key " + splitted[0] + " when already received, ignoring!" );
} else {
@@ -193,10 +194,10 @@ public abstract class Transfer
}
} catch ( SocketTimeoutException ste ) {
sendErrorCode( "timeout" );
- this.close( "Socket Timeout occured in readMetaData. " + ERROR );
+ this.close( "Socket Timeout occured in readMetaData." );
return null;
} catch ( Exception e ) {
- this.close( "Exception occured in readMetaData: " + e.toString() + " " + ERROR );
+ this.close( "Exception occured in readMetaData: " + e.toString() );
return null;
}
return new MetaData( entries );
@@ -284,7 +285,7 @@ public abstract class Transfer
*/
public String getRemoteError()
{
- return ERROR;
+ return remoteError;
}
/**
diff --git a/src/main/java/org/openslx/filetransfer/Uploader.java b/src/main/java/org/openslx/filetransfer/Uploader.java
index a1ad313..6edc268 100644
--- a/src/main/java/org/openslx/filetransfer/Uploader.java
+++ b/src/main/java/org/openslx/filetransfer/Uploader.java
@@ -162,6 +162,10 @@ public class Uploader extends Transfer
}
if ( meta.isDone() ) // Download complete?
break;
+ if ( getRemoteError() != null ) {
+ this.close( "Remote peer sent error: " + getRemoteError(), callback, true );
+ return false;
+ }
// Not complete, so there must be another range request
FileRange requestedRange = meta.getRange();
if ( requestedRange == null ) {