From 8c7d35f605fc0f8ff50136fb83c31d42a85b82aa Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Mon, 10 Jul 2023 14:34:34 +0200 Subject: [filetransfer] Improve error logging --- src/main/java/org/openslx/filetransfer/Downloader.java | 8 ++++++-- src/main/java/org/openslx/filetransfer/FileRange.java | 6 ++++++ src/main/java/org/openslx/filetransfer/Transfer.java | 16 ++++++++++++++++ 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/openslx/filetransfer/Downloader.java b/src/main/java/org/openslx/filetransfer/Downloader.java index b2dbbd1..c79810d 100644 --- a/src/main/java/org/openslx/filetransfer/Downloader.java +++ b/src/main/java/org/openslx/filetransfer/Downloader.java @@ -203,8 +203,12 @@ public class Downloader extends Transfer return false; } FileRange remoteRange = meta.getRange(); - if ( remoteRange == null || !remoteRange.equals( requestedRange ) ) { - log.error( "Confirmed range by remote peer does not match requested range, aborting download." ); + if ( remoteRange == null ) { + log.error( "Remote metadata does not contain range confirmation. " + meta ); + } + if ( !remoteRange.equals( requestedRange ) ) { + log.error( "Confirmed range by remote peer (" + remoteRange + + ") does not match requested range (" + requestedRange + "), aborting download." ); return false; } // Receive requested range diff --git a/src/main/java/org/openslx/filetransfer/FileRange.java b/src/main/java/org/openslx/filetransfer/FileRange.java index e8a7d12..ed86e51 100644 --- a/src/main/java/org/openslx/filetransfer/FileRange.java +++ b/src/main/java/org/openslx/filetransfer/FileRange.java @@ -64,4 +64,10 @@ public class FileRange return (int)startOffset ^ Integer.rotateLeft( (int)endOffset, 16 ) ^ (int)(startOffset >> 32); } + @Override + public String toString() + { + return startOffset + "-" + endOffset; + } + } diff --git a/src/main/java/org/openslx/filetransfer/Transfer.java b/src/main/java/org/openslx/filetransfer/Transfer.java index 933e63e..4b15e60 100644 --- a/src/main/java/org/openslx/filetransfer/Transfer.java +++ b/src/main/java/org/openslx/filetransfer/Transfer.java @@ -9,6 +9,7 @@ import java.net.Socket; import java.net.SocketTimeoutException; import java.util.HashMap; import java.util.Map; +import java.util.Map.Entry; import javax.net.ssl.SSLContext; import javax.net.ssl.SSLSocketFactory; @@ -417,6 +418,21 @@ public abstract class Transfer return meta.containsKey( "COMPRESS" ); } + @Override + public String toString() + { + StringBuilder sb = new StringBuilder(); + for ( Entry it : meta.entrySet() ) { + if ( sb.length() != 0 ) { + sb.append( ' ' ); + } + sb.append( it.getKey() ); + sb.append( '=' ); + sb.append( it.getValue() ); + } + return sb.toString(); + } + } } -- cgit v1.2.3-55-g7522