summaryrefslogtreecommitdiffstats
path: root/src/main/java/org/openslx/filetransfer/util/IncomingTransferBase.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/org/openslx/filetransfer/util/IncomingTransferBase.java')
-rw-r--r--src/main/java/org/openslx/filetransfer/util/IncomingTransferBase.java52
1 files changed, 29 insertions, 23 deletions
diff --git a/src/main/java/org/openslx/filetransfer/util/IncomingTransferBase.java b/src/main/java/org/openslx/filetransfer/util/IncomingTransferBase.java
index a1d3548..8a69020 100644
--- a/src/main/java/org/openslx/filetransfer/util/IncomingTransferBase.java
+++ b/src/main/java/org/openslx/filetransfer/util/IncomingTransferBase.java
@@ -145,6 +145,9 @@ public abstract class IncomingTransferBase extends AbstractTransfer implements H
localCopyManager.interrupt();
}
safeClose( tmpFileHandle );
+ if ( getTransferInfo() != null && getTransferInfo().token != null ) {
+ LOGGER.debug( "Cancelled upload " + getTransferInfo().token );
+ }
}
@Override
@@ -460,34 +463,37 @@ public abstract class IncomingTransferBase extends AbstractTransfer implements H
@Override
public void run()
{
- CbHandler cbh = new CbHandler( connection );
- if ( connection.download( cbh, cbh ) ) {
- connectFails.set( 0 );
- } else {
- connectFails.incrementAndGet();
- if ( cbh.currentChunk != null ) {
- // If the download failed and we have a current chunk, put it back into
- // the queue, so it will be handled again later...
- chunks.markFailed( cbh.currentChunk );
- // Possibly queue for local copy
- if ( localCopyManager != null && cbh.currentChunk.sha1sum != null ) {
- List<byte[]> lst = new ArrayList<>( 1 );
- lst.add( cbh.currentChunk.sha1sum );
- checkLocalCopyCandidates( lst, 0 );
+ try {
+ CbHandler cbh = new CbHandler( connection );
+ if ( connection.download( cbh, cbh ) ) {
+ connectFails.set( 0 );
+ } else {
+ connectFails.incrementAndGet();
+ if ( cbh.currentChunk != null ) {
+ // If the download failed and we have a current chunk, put it back into
+ // the queue, so it will be handled again later...
+ chunks.markFailed( cbh.currentChunk );
+ // Possibly queue for local copy
+ if ( localCopyManager != null && cbh.currentChunk.sha1sum != null ) {
+ List<byte[]> lst = new ArrayList<>( 1 );
+ lst.add( cbh.currentChunk.sha1sum );
+ checkLocalCopyCandidates( lst, 0 );
+ }
+ chunkStatusChanged( cbh.currentChunk );
}
- chunkStatusChanged( cbh.currentChunk );
+ LOGGER.debug( "Connection for " + getTmpFileName().getAbsolutePath() + " dropped" );
+ }
+ if ( state != TransferState.FINISHED && state != TransferState.ERROR ) {
+ lastActivityTime.set( System.currentTimeMillis() );
+ }
+ } finally {
+ synchronized ( downloads ) {
+ downloads.remove( connection );
}
- LOGGER.debug( "Connection for " + getTmpFileName().getAbsolutePath() + " dropped" );
- }
- if ( state != TransferState.FINISHED && state != TransferState.ERROR ) {
- lastActivityTime.set( System.currentTimeMillis() );
- }
- synchronized ( downloads ) {
- downloads.remove( connection );
}
if ( chunks.isComplete() ) {
finishUploadInternal();
- } else {
+ } else if ( state == TransferState.WORKING ) {
// Keep pumping unhashed chunks into the hasher
queueUnhashedChunk( true );
if ( localCopyManager != null ) {