You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by "graben (via GitHub)" <gi...@apache.org> on 2023/11/30 19:17:19 UTC

[PR] Add checksum feature to camel-file/ftp [camel]

graben opened a new pull request, #12280:
URL: https://github.com/apache/camel/pull/12280

   (no comment)


-- 
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-unsubscribe@camel.apache.org

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


Re: [PR] Add checksum feature to camel-file/ftp [camel]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #12280:
URL: https://github.com/apache/camel/pull/12280#issuecomment-1834404119

   :star2: Thank you for your contribution to the Apache Camel project! :star2: 
   
   :robot: CI automation will test this PR automatically.
   
   :camel: Apache Camel Committers, please review the following items:
   
   * First-time contributors **require MANUAL approval** for the GitHub Actions to run
   
   * You can use the command `/component-test (camel-)component-name1 (camel-)component-name2..` to request a test from the test bot.
   
   * You can label PRs using `build-all`, `build-dependents`, `skip-tests` and `test-dependents` to fine-tune the checks executed by this PR.
   
   * Build and test logs are available in the Summary page. **Only** [Apache Camel committers](https://camel.apache.org/community/team/#committers) have access to the summary. 
   
   * :warning: Be careful when sharing logs. Review their contents before sharing them publicly.


-- 
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-unsubscribe@camel.apache.org

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


Re: [PR] CAMEL-20172: Add checksum feature to camel-file/ftp [camel]

Posted by "orpiske (via GitHub)" <gi...@apache.org>.
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-unsubscribe@camel.apache.org

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


Re: [PR] CAMEL-20172: Add checksum feature to camel-file/ftp [camel]

Posted by "graben (via GitHub)" <gi...@apache.org>.
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: commits-unsubscribe@camel.apache.org

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


Re: [PR] CAMEL-20172: Add checksum feature to camel-file/ftp [camel]

Posted by "davsclaus (via GitHub)" <gi...@apache.org>.
davsclaus merged PR #12280:
URL: https://github.com/apache/camel/pull/12280


-- 
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-unsubscribe@camel.apache.org

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