Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Equinox » SimpleArtifactRepository file removal logic(To clarify whether the logic in place is valid)
SimpleArtifactRepository file removal logic [message #1842499] Mon, 21 June 2021 17:48 Go to next message
Adam Saturna is currently offline Adam SaturnaFriend
Messages: 4
Registered: March 2021
Junior Member
Hello,

I'm reaching out in hopes to better understand how SimpleArtifactRepository's doRemoveArtifact method works.

When our application starts we perform a rebuild / validation of our artifact repository. One of the IPublisherActions executed will trigger a FolderEntryAdvice that will add some properties to the artifact meta file such as "artifact.folder", "file.name", "file.lastModified", and "artifact.reference".

The last one, "artifact.reference" seems to have an adverse effect when we are trying to update a feature. Namely, the old bundle jar file doesn't get removed from "plugins" directory, but the artifact definition does get removed from artifacts.xml, leaving us with an orphaned .jar file.

I was looking into some source code for SimpleArtifactRepository's doRemoveArtifact which looks as follows:

/**
	 * Removes the given descriptor, and the physical artifact corresponding
	 * to that descriptor. Returns <code>true</code> if and only if the
	 * descriptor existed in the repository, and was successfully removed.
	 */
	private boolean doRemoveArtifact(IArtifactDescriptor descriptor) {
		SimpleArtifactDescriptor simple = null;
		if (descriptor instanceof SimpleArtifactDescriptor)
			simple = (SimpleArtifactDescriptor) descriptor;
		else
			simple = createInternalDescriptor(descriptor);
		if (simple.getRepositoryProperty(SimpleArtifactDescriptor.ARTIFACT_REFERENCE) == null) {
			File file = getArtifactFile(descriptor);
			if (file != null) {
				// If the file != null remove it, otherwise just remove
				// the descriptor
				delete(file);
				if (file.exists())
					return false;
			}
		}
		boolean result = artifactDescriptors.remove(descriptor);
		if (result)
			unmapDescriptor(descriptor);

		return result;
	}


You can see that if "artifact.reference" is present, it will not try to remove the file. Is this correct? Could someone explain why this is done?

As a fix, I have removed adding "artifact.reference" meta information. After doing so, old jar deletion works again. But my question above remains.

Any clarification would be much appreciated.
Re: SimpleArtifactRepository file removal logic [message #1842512 is a reply to message #1842499] Tue, 22 June 2021 05:34 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 32494
Registered: July 2009
Senior Member
I'm not sure anyone is around to explain the original intent of the design...

In org.eclipse.equinox.internal.p2.artifact.repository.simple.SimpleArtifactRepository.getLocation(IArtifactDescriptor) there is a comment "if the artifact is just a reference then return the reference location":

https://git.eclipse.org/c/equinox/rt.equinox.p2.git/tree/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/simple/SimpleArtifactRepository.java#n942

This suggests to me that the expectation is perhaps that an artifact descriptor with a reference isn't expected to necessarily refer to an artifact physically located in the simple repository.

The use of the specific properties you've mentioned in org.eclipse.equinox.internal.provisional.p2.directorywatcher.RepositoryListener

https://git.eclipse.org/c/equinox/rt.equinox.p2.git/tree/bundles/org.eclipse.equinox.p2.directorywatcher/src/org/eclipse/equinox/internal/provisional/p2/directorywatcher/RepositoryListener.java#n38

also suggests that these are properties used on artifact descriptors that are not managed as physical contents of a simple repository...


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:Activate capability when feature is installed
Next Topic:Configure Jetty to use HTTPS
Goto Forum:
  


Current Time: Wed Sep 28 10:55:05 GMT 2022

Powered by FUDForum. Page generated in 0.02078 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top