SimpleArtifactRepository file removal logic [message #1842499] |
Mon, 21 June 2021 17:48 |
Adam Saturna 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.
|
|
|
|
Powered by
FUDForum. Page generated in 0.03140 seconds