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


##########
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:
   Done



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to