This commit is contained in:
Jaikiran Pai 2018-09-10 19:03:42 +05:30
parent 969ba77e95
commit ab8112ea24
2 changed files with 2 additions and 22 deletions

View File

@ -20,9 +20,6 @@ package org.apache.ivy.core.cache;
import org.apache.ivy.core.module.descriptor.Artifact;
import org.apache.ivy.util.Checks;
import java.net.MalformedURLException;
import java.net.URL;
/**
* This class contains information about the origin of an artifact.
*
@ -113,23 +110,6 @@ public class ArtifactOrigin {
this.location = location;
}
// the "location" of an ArtifactOrigin is expected to be URL. However,
// in certain versions of Ivy we used to save just the path as the location
// instead of the URL form. Here we try and read it as a URL. If it can be
// read as a URL, we return the URL#getPath. However, if it can't be read
// as a URL, then considering backward compatibility, we treat the "location"
// as a path and return it back.
String getLocationPath() {
if (this.location == null) {
return null;
}
try {
return new URL(this.location).getPath();
} catch (MalformedURLException e) {
return this.location;
}
}
/**
* Return the artifact that this location is pointing at.
*

View File

@ -384,7 +384,7 @@ public class DefaultRepositoryCacheManager implements RepositoryCacheManager, Iv
public File getArchiveFileInCache(Artifact artifact, ArtifactOrigin origin) {
File archive = new File(getRepositoryCacheRoot(), getArchivePathInCache(artifact, origin));
if (!archive.exists() && !ArtifactOrigin.isUnknown(origin) && origin.isLocal()) {
File original = Checks.checkAbsolute(origin.getLocationPath(), artifact
File original = Checks.checkAbsolute(origin.getLocation(), artifact
+ " origin location");
if (original.exists()) {
return original;
@ -406,7 +406,7 @@ public class DefaultRepositoryCacheManager implements RepositoryCacheManager, Iv
*/
private File getArchiveFileInCache(Artifact artifact, ArtifactOrigin origin, boolean useOrigin) {
if (useOrigin && !ArtifactOrigin.isUnknown(origin) && origin.isLocal()) {
return Checks.checkAbsolute(origin.getLocationPath(), artifact + " origin location");
return Checks.checkAbsolute(origin.getLocation(), artifact + " origin location");
}
return new File(getRepositoryCacheRoot(), getArchivePathInCache(artifact, origin));
}