Closed peterrosell closed 4 months ago
Interesting finding. It is probably a good idea to cache InputStream object if people just calling it to read reference. I'll check it.
I think this should help: https://github.com/abdolence/sbt-gcs-resolver/pull/67
I created a PR as well as I been testing it during the day to find out a solution. I can try your version and see if it works as expected. Then I can close my PR.
Oh, I just saw you have a PR as well. I think we're doing something similar, sorry for confusion. Thanks for reporting and testing! I tested it on my env and it worked. I've been preparing the release with updated deps etc, so let me know if it doesn't work for you until I release it please.
This should be fixed now in https://github.com/abdolence/sbt-gcs-resolver/releases/tag/v1.10.0
Lovely! I tested it and works fine. Much appreciated! :heart:
I have some more questions about logging and the head request, but i opened two separate issues, #70 and #71 .
When building with
sbt
and usingcoursier
and using this plugin to fetch artifacts from Google Artifact Registry I have noticed that it downloads the same artifact/file 6 times.This is an example from the sbt logs for the artifact
scala-compiler-2.13.3.jar
and I get the same for the sha1 file.I have confirmed this in the back-end by adding a custom remote repository to a virtual repository and checked the logs in the upstream nginx ingress.
When looking in the code I see that creates a new request for every call to
getInputStream
. We don't know howsbt
/coursier
is calling thegetInputStream
method.When looking at the
HttpURLConnection
and how it handles thegetInputStream
calls we see that it opens the input stream once, saves it and returns the sameInputStream
instance for the following calls.I'm also not sure that it's necessary to do the HEAD request is in the
connect
method.I will create a PR with suggested change to reduce the number of requests to speed up builds and lower the load of the repositories.