Skip to content

Commit

Permalink
Remove no longer valid checksum properties
Browse files Browse the repository at this point in the history
Currently Tycho/P2 only *adds* checksums but as some are now disabled
for publish this can lead to the case where an existing checksum is kept
as-is.

This now performs and additional check if there are old checksums and
remove them when recreate the repository.

Fix #2875
  • Loading branch information
laeubi committed May 31, 2024
1 parent 13489c6 commit 66a0478
Showing 1 changed file with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,22 @@ private MultiStatus recreateRepository(IProgressMonitor monitor) throws Provisio
}
Map<String, String> checksumsToProperties = ChecksumUtilities
.checksumsToProperties(IArtifactDescriptor.DOWNLOAD_CHECKSUM, checksums);
//remove checksums that are no longer marked for publishing
String checksumProperty = IArtifactDescriptor.DOWNLOAD_CHECKSUM + ".";
for (String property : newDescriptor.getProperties().keySet().toArray(String[]::new)) {
if (property.startsWith(checksumProperty)) {
String id = property.substring(checksumProperty.length());
if (checksumsToProperties.containsKey(id)) {
continue;
}
newDescriptor.setProperty(checksumProperty + id, null);
}
}
//remove legacy property if present
if (!checksumsToProperties.containsKey("md5")) {
newDescriptor.setProperty("download.md5", null);
}
newDescriptor.addProperties(checksumsToProperties);

repository.addDescriptor(newDescriptor, null);
}
}
Expand Down

0 comments on commit 66a0478

Please sign in to comment.