orpiske commented on code in PR #12280:
URL: https://github.com/apache/camel/pull/12280#discussion_r1411292017


##########
components/camel-file/src/main/java/org/apache/camel/component/file/GenericFileProducer.java:
##########
@@ -212,6 +215,28 @@ protected void processExchange(Exchange exchange, String 
target) throws Exceptio
                 }
             }
 
+            // any checksum file to write?
+            if (endpoint.getChecksumFileAlgorithm() != null) {
+                String algorithm = endpoint.getChecksumFileAlgorithm();
+                String checksumFileName = target + "." + algorithm;
+
+                // create exchange with checksum as body to write as the 
checksum file
+                MessageHelper.resetStreamCache(exchange.getIn());
+                InputStream is = 
exchange.getIn().getMandatoryBody(InputStream.class);
+                Exchange checksumExchange = new DefaultExchange(exchange);
+                checksumExchange.getIn().setBody(new 
DigestUtils(algorithm).digestAsHex(is));
+
+                LOG.trace("Writing checksum file: [{}]", checksumFileName);
+                // delete any existing done file
+                if (operations.existsFile(checksumFileName)) {
+                    if (!operations.deleteFile(checksumFileName)) {
+                        throw new GenericFileOperationFailedException(
+                                "Cannot delete existing checksum file: " + 
checksumFileName);
+                    }
+                }
+                writeFile(checksumExchange, checksumFileName);

Review Comment:
   Maybe move this block to a separate method? We have far too much methods / 
classes that are far too large and we have been broken them in smaller pieces. 
This would help this effort.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@camel.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to