diff options
author | Andrew Niefer | 2008-11-07 22:48:07 +0000 |
---|---|---|
committer | Andrew Niefer | 2008-11-07 22:48:07 +0000 |
commit | 7d9a584f45f00d076689a9d99c4f72a375aba712 (patch) | |
tree | e9a8b194ad897bbf03743a184f9dfa998a780460 /bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/simple/SimpleArtifactRepository.java | |
parent | ef842010713a46f5788aa727ffb6ff21bb15580b (diff) | |
download | rt.equinox.p2-7d9a584f45f00d076689a9d99c4f72a375aba712.tar.gz rt.equinox.p2-7d9a584f45f00d076689a9d99c4f72a375aba712.tar.xz rt.equinox.p2-7d9a584f45f00d076689a9d99c4f72a375aba712.zip |
bug 249035 - identity of ArtifactDescriptor
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/simple/SimpleArtifactRepository.java')
-rw-r--r-- | bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/simple/SimpleArtifactRepository.java | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/simple/SimpleArtifactRepository.java b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/simple/SimpleArtifactRepository.java index 4a815e948..672549529 100644 --- a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/simple/SimpleArtifactRepository.java +++ b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/simple/SimpleArtifactRepository.java @@ -171,7 +171,6 @@ public class SimpleArtifactRepository extends AbstractArtifactRepository impleme } private static final String ARTIFACT_FOLDER = "artifact.folder"; //$NON-NLS-1$ - private static final String ARTIFACT_REFERENCE = "artifact.reference"; //$NON-NLS-1$ private static final String ARTIFACT_UUID = "artifact.uuid"; //$NON-NLS-1$ static final private String BLOBSTORE = ".blobstore/"; //$NON-NLS-1$ static final private String CONTENT_FILENAME = "artifacts"; //$NON-NLS-1$ @@ -399,7 +398,7 @@ public class SimpleArtifactRepository extends AbstractArtifactRepository impleme * descriptor existed in the repository, and was successfully removed. */ private boolean doRemoveArtifact(IArtifactDescriptor descriptor) { - if (((ArtifactDescriptor) descriptor).getRepositoryProperty(ARTIFACT_REFERENCE) == null) { + if (((ArtifactDescriptor) descriptor).getRepositoryProperty(ArtifactDescriptor.ARTIFACT_REFERENCE) == null) { File file = getArtifactFile(descriptor); if (file == null) return false; @@ -631,7 +630,7 @@ public class SimpleArtifactRepository extends AbstractArtifactRepository impleme try { // if the artifact is just a reference then return the reference location if (descriptor instanceof ArtifactDescriptor) { - String artifactReference = ((ArtifactDescriptor) descriptor).getRepositoryProperty(ARTIFACT_REFERENCE); + String artifactReference = ((ArtifactDescriptor) descriptor).getRepositoryProperty(ArtifactDescriptor.ARTIFACT_REFERENCE); if (artifactReference != null) { try { return new URI(artifactReference); @@ -675,17 +674,19 @@ public class SimpleArtifactRepository extends AbstractArtifactRepository impleme public OutputStream getOutputStream(IArtifactDescriptor descriptor) throws ProvisionException { assertModifiable(); - // Check if the artifact is already in this repository - if (contains(descriptor)) { - String msg = NLS.bind(Messages.available_already_in, getLocation().toString()); - throw new ProvisionException(new Status(IStatus.ERROR, Activator.ID, ProvisionException.ARTIFACT_EXISTS, msg, null)); - } - // create a copy of the original descriptor that we can manipulate + // Create a copy of the original descriptor that we can manipulate and add to our repo. ArtifactDescriptor newDescriptor = new ArtifactDescriptor(descriptor); if (isFolderBased(descriptor)) newDescriptor.setRepositoryProperty(ARTIFACT_FOLDER, Boolean.TRUE.toString()); + // Check if the artifact is already in this repository, check the newDescriptor instead of the original + // since the implementation of hash/equals on the descriptor matters here. + if (contains(newDescriptor)) { + String msg = NLS.bind(Messages.available_already_in, getLocation().toString()); + throw new ProvisionException(new Status(IStatus.ERROR, Activator.ID, ProvisionException.ARTIFACT_EXISTS, msg, null)); + } + // Determine writing location URI newLocation = createLocation(newDescriptor); if (newLocation == null) |