From 552f88cff3ba319513035af31dda60ee6d40bc8a Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Fri, 17 Jul 2015 17:25:27 +0200 Subject: [server] Handle cancel() for Uploads, Mark blocks as complete --- .../main/java/org/openslx/bwlp/sat/fileserv/ActiveUpload.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'dozentenmodulserver/src/main/java') diff --git a/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/fileserv/ActiveUpload.java b/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/fileserv/ActiveUpload.java index dbeb24ae..49cfed56 100644 --- a/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/fileserv/ActiveUpload.java +++ b/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/fileserv/ActiveUpload.java @@ -7,7 +7,6 @@ import java.io.RandomAccessFile; import java.nio.ByteBuffer; import java.sql.SQLException; import java.util.List; -import java.util.UUID; import java.util.concurrent.ThreadPoolExecutor; import org.apache.log4j.Logger; @@ -202,8 +201,10 @@ public class ActiveUpload { } public synchronized void cancel() { - // TODO Auto-generated method stub - + if (download != null) // TODO: Thread safety + download.close("Cancelled"); + if (state != TransferState.FINISHED) + state = TransferState.ERROR; } /** @@ -251,6 +252,8 @@ public class ActiveUpload { if (currentChunk != null) { // TODO: A chunk was requested before, check hash and requeue if not matching // This needs to be async (own thread) so will be a little complicated + // For now, we just mark it as complete + chunks.markSuccessful(currentChunk); LOGGER.info("There was a previous chunk!"); } // Get next missing chunk -- cgit v1.2.3-55-g7522