diff options
Diffstat (limited to 'src/main/java/org/openslx/imagemaster/serverconnection/ImageProcessor.java')
-rw-r--r-- | src/main/java/org/openslx/imagemaster/serverconnection/ImageProcessor.java | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/src/main/java/org/openslx/imagemaster/serverconnection/ImageProcessor.java b/src/main/java/org/openslx/imagemaster/serverconnection/ImageProcessor.java index 8306280..10580a7 100644 --- a/src/main/java/org/openslx/imagemaster/serverconnection/ImageProcessor.java +++ b/src/main/java/org/openslx/imagemaster/serverconnection/ImageProcessor.java @@ -64,8 +64,6 @@ public class ImageProcessor // check image data // TODO: do security checks - log.debug( "Trying to answer request:" + serverSessionId + ", " + imageData + ", " + crcSums ); - String uuid = imageData.uuid; String token; String filepath; @@ -77,7 +75,7 @@ public class ImageProcessor synchronized ( uploadingImages ) { // check if image is already uploading TODO: what if two clients call this at the same time? -> Good question.. (Thought about not sending the last requested. But then the upload will never finish...) if ( ( image = uploadingImages.get( uuid ) ) != null ) { - log.debug( "Image is already uploading" ); + log.debug( "Image is already uploading.. returning some missing blocks" ); List<Integer> missing = getNMissingBlocks( image, AMOUNT ); if ( missing.isEmpty() ) { uploadDone( uuid ); @@ -87,7 +85,6 @@ public class ImageProcessor } // insert new image - log.debug( "Inserting new download" ); filepath = Globals.getImageDir() + "/" + uuid + ".vmdk"; token = RandomString.generate( 100, false ); crcPath = Globals.getImageDir() + "/" + uuid + ".crc"; @@ -103,7 +100,7 @@ public class ImageProcessor try { new CRCFile( crcSums, crcPath); } catch (IOException e) { - log.debug( "Could not create crc file" ); + log.error( "Could not create crc file", e ); return null; // TODO: what to do if we can not write the crc file to disk? Give object to crcscheduler? } @@ -111,7 +108,7 @@ public class ImageProcessor DbImage.insert( imageData, System.currentTimeMillis(), token, allBlocks, serverSessionId, filepath ); imagesToCheck.add( uuid ); - log.debug( "Returning UploadInfos" ); + log.debug( "Returning UploadInfos. Client should goint to start the upload. " ); return new UploadInfos( token, Globals.getSslSocketPort(), getNMissingBlocks( image, AMOUNT ) ); } @@ -148,13 +145,14 @@ public class ImageProcessor // insert new client and start listener synchronized ( downloadingClients ) { - DownloadingClient client = new DownloadingClient(); String token = RandomString.generate( 100, false ); String filepath = DbImage.getImageByUUID( uuid ).imagePath; - ConnectionHandler.addConnection( token, filepath, Connection.DOWNLOADING ); + DownloadingClient client = new DownloadingClient(); client.addDownload( uuid, requestedBlocks, token ); downloadingClients.put( serverSessionId, client ); + + ConnectionHandler.addConnection( token, filepath, Connection.DOWNLOADING ).client = client; return new DownloadInfos( token, Globals.getSslSocketPort() ); } } @@ -226,6 +224,11 @@ public class ImageProcessor return result; } + public static List<Integer> getRequestedBlocks( String token) { + + return null; + } + /** * Checks pending uploads in database and adds them to process list again. */ |