thomasmueller commented on code in PR #2607:
URL: https://github.com/apache/jackrabbit-oak/pull/2607#discussion_r2494407115
##########
oak-run/src/main/java/org/apache/jackrabbit/oak/run/Downloader.java:
##########
@@ -170,29 +183,86 @@ public ItemResponse call() throws Exception {
Path destinationPath = Paths.get(item.destination);
Files.createDirectories(destinationPath.getParent());
+ long segmentSize = MAX_LENGTH_SINGLE_THREADED;
long size = 0;
- try (InputStream inputStream = sourceUrl.getInputStream();
- FileOutputStream outputStream = new
FileOutputStream(destinationPath.toFile())) {
- byte[] buffer = new byte[bufferSize];
- int bytesRead;
- while ((bytesRead = inputStream.read(buffer)) != -1) {
- if (md != null) {
- md.update(buffer, 0, bytesRead);
+ if (item.length >= segmentSize) {
+ size = item.length;
Review Comment:
I thought about that, but it would add additional complexity, because we
need to have fields for the various variables then... I think in this case it's
not worth it, because we only use the code in one place. This is the discussion
"spagetti code vs ravioli code", which is described in detail here:
https://wiki.c2.com/?RavioliCode
In general, I try to use separate function if an algorithm can be / is
called from multiple places. Also, static functions are nice, because they can
be tested more easily. But here, this doesn't apply.
--
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]