diff --git a/addons/pkg-npm/common/src/main/java/org/commonjava/indy/pkg/npm/content/PackageMetadataGenerator.java b/addons/pkg-npm/common/src/main/java/org/commonjava/indy/pkg/npm/content/PackageMetadataGenerator.java index f490a103a7..f8289bf14b 100644 --- a/addons/pkg-npm/common/src/main/java/org/commonjava/indy/pkg/npm/content/PackageMetadataGenerator.java +++ b/addons/pkg-npm/common/src/main/java/org/commonjava/indy/pkg/npm/content/PackageMetadataGenerator.java @@ -321,11 +321,19 @@ private boolean writePackageMetadata( List firstLevelFiles, Artif } // Generate tarball url if missing + String tarball = "http://indy/" + packagePath.getTarPath(); // here we use mock host. indy will amend it with the right hostname if ( versionMetadata.getDist() == null ) { - String tarball = "http://indy/" + packagePath.getTarPath(); // here we use mock host. indy will amend it with the right hostname //logger.debug( "Generate dist tarball: {}", tarball ); - versionMetadata.setDist( new Dist( tarball ) ); + versionMetadata.setDist( new Dist( tarball ) ); + } else { + // Detect bad tarball and replace with correct one + if ( versionMetadata.getDist().getTarball() == null || !versionMetadata.getDist().getTarball().endsWith(packagePath.getTarPath()) ) + { + Dist dist = versionMetadata.getDist(); + dist.setTarball( tarball ); + versionMetadata.setDist( dist ); + } } } catch ( IOException e ) diff --git a/addons/pkg-npm/model-java/src/main/java/org/commonjava/indy/pkg/npm/model/Dist.java b/addons/pkg-npm/model-java/src/main/java/org/commonjava/indy/pkg/npm/model/Dist.java index cf0ae0c680..4d70edbfce 100644 --- a/addons/pkg-npm/model-java/src/main/java/org/commonjava/indy/pkg/npm/model/Dist.java +++ b/addons/pkg-npm/model-java/src/main/java/org/commonjava/indy/pkg/npm/model/Dist.java @@ -25,7 +25,7 @@ public class Dist private final String shasum; - private final String tarball; + private String tarball; private final String integrity; @@ -69,6 +69,11 @@ public String getTarball() return tarball; } + public void setTarball( String tarball ) + { + this.tarball = tarball; + } + public String getIntegrity() { return integrity;