From ab0b4c2d75ed93724c7bb9e3932cf79f7b1b26d7 Mon Sep 17 00:00:00 2001 From: Björn Hagemeister Date: Tue, 30 Sep 2014 18:29:37 +0200 Subject: Handling case, if no *.crc file is available plus adding upload complete message if done. --- .../filetransfer/ThriftConnection.java | 32 ++++++++++++++-------- 1 file changed, 20 insertions(+), 12 deletions(-) (limited to 'src/main/java/org/openslx/satellitedaemon/filetransfer/ThriftConnection.java') diff --git a/src/main/java/org/openslx/satellitedaemon/filetransfer/ThriftConnection.java b/src/main/java/org/openslx/satellitedaemon/filetransfer/ThriftConnection.java index 673be05..614fb24 100644 --- a/src/main/java/org/openslx/satellitedaemon/filetransfer/ThriftConnection.java +++ b/src/main/java/org/openslx/satellitedaemon/filetransfer/ThriftConnection.java @@ -62,24 +62,32 @@ public class ThriftConnection { * * @return returns 'null' if there is a problem. */ - public static UploadData getUploadInfos(ImageData imDat, String filename) { + public static UploadData getUploadInfos(ImageData imDat, String path) { ImageServer.Client theClient = null; + String crcPath = path.concat(".crc"); try { theClient = getConnection(); if (theClient == null) { log.error("Client was null!"); return null; } - - crc = new CrcFile(filename); - log.info("Made CRCFile from " + filename); - log.info("crc.getCrcSums( ).size = " + crc.getCrcSums().size()); - // log.info( "crc.getMasterSum() : " + crc.getMasterSum() ); - // for ( int i = 0; i < crc.getCrcSums().size() - 1; i++ ) { - // log.info( "crc.getCRCSum() : " + crc.getCRCSum( i ) ); - // } - return theClient - .submitImage(sSD.sessionId, imDat, crc.getCrcSums()); + List crcSums = null; + try { + crc = new CrcFile(crcPath); + log.info("Made CRCFile from " + crcPath); + log.info("crc.getCrcSums( ).size = " + crc.getCrcSums().size()); + // log.info( "crc.getMasterSum() : " + crc.getMasterSum() ); + // for ( int i = 0; i < crc.getCrcSums().size() - 1; i++ ) { + // log.info( "crc.getCRCSum() : " + crc.getCRCSum( i ) ); + // } + crcSums = crc.getCrcSums(); + return theClient + .submitImage(sSD.sessionId, imDat, crcSums); + } catch (FileNotFoundException e) { + log.debug("crcFile " + crcPath + " not found."); + return theClient + .submitImage(sSD.sessionId, imDat, crcSums); + } } catch (ImageDataException e) { if (e.isSetNumber() && e.getNumber().equals(ImageDataError.INVALID_DATA)) { @@ -97,7 +105,7 @@ public class ThriftConnection { } else if (e.getNumber().equals(UploadError.INVALID_CRC)) { // The CRC sum contained errors try { - crc = new CrcFile(filename); + crc = new CrcFile(crcPath); } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); -- cgit v1.2.3-55-g7522