ceylon / ceylon-module-resolver

DEPRECATED
Apache License 2.0
23 stars 9 forks source link

Retrieving multiple artifacts at a time can result in wrong result #110

Closed quintesse closed 10 years ago

quintesse commented 10 years ago

Right now we have a RepositoryManager.getArtifactResults(contexts) method that can efficiently retrieve several artifacts from the same repository... too efficiently perhaps because when the cache is involved the result might actually be wrong.

Imagine the following steps:

  1. There is a remote repository with a module with the artifacts CAR and JS
  2. We ask for JVM
  3. The CAR gets found in the remote repository, retrieved and cached locally
  4. The artifact get returned as a result

Now imagine the next query:

  1. We still have the same remote repository with a module with the artifacts CAR and JS
  2. We ask for CAR and JS
  3. The CAR gets found in the local cache
  4. We now look for JS in the same local cache where it doesn't exist!
  5. Only the CAR gets returned as a result

We need a more intelligent system to deal with this. Perhaps by storing in the cache the fact that we tried to retrieve a certain artifact before but got no result (not an error! we should definitely retry in the future if the result was an error), eg. by adding a foo-1.0.car.missing marker file to the repository.

Edit: simplified description a bit

quintesse commented 10 years ago

On possible solution I can think of is that instead of directly using the Repository that we got from a previous ArtifactResult to retrieve the next artifact we still use the original repository but in the new ArtifactContext we pass a new field searchRepository and we set it to the one we got from the previous result.

Edit: this was basically already working like this

This way we could hopefully do a clever trick where if that preferred repository is the cache and the artifact isn't found and neither does any .missing marker exist, it will then clear the searchRepository field and pass on the request to the original repository.

Edit: and this is more or less what was implemented

quintesse commented 10 years ago

In the end I decided it was worth it to do for 1.1. Closing.