summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/main/java/org/openslx/imagemaster/serverconnection/ConnectionHandler.java5
-rw-r--r--src/main/java/org/openslx/imagemaster/serverconnection/ImageProcessor.java7
-rw-r--r--src/main/java/org/openslx/imagemaster/serverconnection/UploadingImage.java12
3 files changed, 19 insertions, 5 deletions
diff --git a/src/main/java/org/openslx/imagemaster/serverconnection/ConnectionHandler.java b/src/main/java/org/openslx/imagemaster/serverconnection/ConnectionHandler.java
index e6319c9..12b5701 100644
--- a/src/main/java/org/openslx/imagemaster/serverconnection/ConnectionHandler.java
+++ b/src/main/java/org/openslx/imagemaster/serverconnection/ConnectionHandler.java
@@ -186,8 +186,10 @@ public class ConnectionHandler implements IncomingEvent
}
// get start of range.
int blockNumber = image.getNextMissingBlock();
- if ( blockNumber == -1 )
+ if ( blockNumber == -1 ) {
+ log.debug( "Download complete." );
return null;
+ }
lastBlock.setValue( blockNumber );
log.debug( "Block " + blockNumber + " was transmitted " + image.getTimesTransmitted( blockNumber ) + " time(s)." );
@@ -197,6 +199,7 @@ public class ConnectionHandler implements IncomingEvent
return range;
}
} );
+ image.updateDb();
}
} );
} catch ( RejectedExecutionException e ) {
diff --git a/src/main/java/org/openslx/imagemaster/serverconnection/ImageProcessor.java b/src/main/java/org/openslx/imagemaster/serverconnection/ImageProcessor.java
index 739bc62..81a3e75 100644
--- a/src/main/java/org/openslx/imagemaster/serverconnection/ImageProcessor.java
+++ b/src/main/java/org/openslx/imagemaster/serverconnection/ImageProcessor.java
@@ -70,7 +70,12 @@ public class ImageProcessor
final String uuid = imageData.uuid;
final String filepathRelative;
- final CrcFile crcFile = new CrcFile( crcSums );
+ final CrcFile crcFile;
+ if ( crcSums == null) {
+ crcFile = null;
+ } else {
+ crcFile = new CrcFile( crcSums );
+ }
UploadingImage image;
synchronized ( uploadingImages ) {
diff --git a/src/main/java/org/openslx/imagemaster/serverconnection/UploadingImage.java b/src/main/java/org/openslx/imagemaster/serverconnection/UploadingImage.java
index 78d5f2b..4d51ef9 100644
--- a/src/main/java/org/openslx/imagemaster/serverconnection/UploadingImage.java
+++ b/src/main/java/org/openslx/imagemaster/serverconnection/UploadingImage.java
@@ -88,14 +88,18 @@ public class UploadingImage
protected void setNeedsCheck( int index )
{
synchronized ( blockStatus ) {
- blockStatus[index] = -Math.abs( blockStatus[index] ); // switch to negative value if needed
+ if ( crcFile == null ) {
+ blockStatus[index] = VALID;
+ } else {
+ blockStatus[index] = -Math.abs( blockStatus[index] ); // switch to negative value if needed
+ }
}
}
protected void increaseTransmittedTimes( int index )
{
synchronized ( blockStatus ) {
- if ( blockStatus[index] == 200 )
+ if ( blockStatus[index] == VALID )
return;
blockStatus[index] += ( blockStatus[index] <= MISSING ) ? -1 : 1; // increase in both directions
}
@@ -176,7 +180,9 @@ public class UploadingImage
protected void setCrcFile( CrcFile crcFile )
{
- if ( getCrcFile() == null ) {
+ if ( crcFile == null )
+ return;
+ if ( getCrcFile() == null && crcFile.isValid() ) {
this.crcFile = crcFile;
try {
crcFile.writeCrcFile( dbImage.getAbsolutePath() + ".crc" );