[ https://issues.apache.org/jira/browse/MRESOLVER-276?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17615339#comment-17615339 ]
ASF GitHub Bot commented on MRESOLVER-276: ------------------------------------------ cstamas commented on code in PR #200: URL: https://github.com/apache/maven-resolver/pull/200#discussion_r991617082 ########## maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/checksum/SummaryFileTrustedChecksumsSource.java: ########## @@ -159,9 +178,63 @@ private ConcurrentHashMap<String, String> loadProvidedChecksums( Path checksumsF } else { - LOGGER.debug( "Checksums file '{}' not found", checksumsFile ); + LOGGER.debug( "The {} trusted checksums for remote repository {} not exist at '{}'", + checksumAlgorithmFactory.getName(), artifactRepository.getId(), checksumsFile ); } return result; } + + private String calculateSummaryPath( boolean originAware, + ArtifactRepository artifactRepository, + ChecksumAlgorithmFactory checksumAlgorithmFactory ) + { + final String fileName; + if ( originAware ) + { + fileName = CHECKSUMS_FILE_PREFIX + "-" + artifactRepository.getId(); + } + else + { + fileName = CHECKSUMS_FILE_PREFIX; + } + return fileName + "." + checksumAlgorithmFactory.getFileExtension(); + } + + private class SummaryFileWriter implements Writer + { + private final Path basedir; + + private final boolean originAware; + + private SummaryFileWriter( Path basedir, boolean originAware ) + { + this.basedir = basedir; + this.originAware = originAware; + } + + @Override + public void addTrustedArtifactChecksums( Artifact artifact, ArtifactRepository artifactRepository, + List<ChecksumAlgorithmFactory> checksumAlgorithmFactories, + Map<String, String> trustedArtifactChecksums ) throws IOException + { + for ( ChecksumAlgorithmFactory checksumAlgorithmFactory : checksumAlgorithmFactories ) + { + String checksum = requireNonNull( + trustedArtifactChecksums.get( checksumAlgorithmFactory.getName() ) ); + String summaryLine = ArtifactIdUtils.toId( artifact ) + " " + checksum + "\n"; + Path summaryPath = basedir.resolve( + calculateSummaryPath( originAware, artifactRepository, checksumAlgorithmFactory ) ); + Files.createDirectories( summaryPath.getParent() ); + Files.write( summaryPath, summaryLine.getBytes( StandardCharsets.UTF_8 ), + StandardOpenOption.CREATE, StandardOpenOption.WRITE, StandardOpenOption.APPEND ); Review Comment: Yes, as discussed already, this will work only in T1 model. Now that Writers are Closeable, they can do better: they can buffer writes, and spit out on close, or ultimately (once added) write should happen "on session close", something not yet present. > Resolver post-processor > ----------------------- > > Key: MRESOLVER-276 > URL: https://issues.apache.org/jira/browse/MRESOLVER-276 > Project: Maven Resolver > Issue Type: Improvement > Components: Resolver > Reporter: Tamas Cservenak > Assignee: Tamas Cservenak > Priority: Major > Fix For: resolver-next > > > Introduce new feature, resolver post-processor that is able to post process > resolution results just before artifact resolver returns them to caller. Post > processor should be able to signal resolution failure (along with errors) > just like existing resolution may fail. -- This message was sent by Atlassian Jira (v8.20.10#820010)