@NotNull private List<String> getPathsToDelete(@NotNull ArtifactListData artifactsInfo, @NotNull String patterns, @NotNull String pathPrefix) throws IOException { final List<String> keys = CollectionsUtil.convertCollection(artifactsInfo.getArtifactList(), ArtifactData::getPath); return new ArrayList<>(new PathPatternFilter(patterns).filterPaths(keys)); }
@Override public int publishFiles(@NotNull final Map<File, String> map) throws ArtifactPublishingFailedException { Map<File, String> filteredMap = CollectionsUtil.filterMapByValues(map, new Filter<String>() { @Override public boolean accept(@NotNull String s) { return !s.startsWith(ArtifactsConstants.TEAMCITY_ARTIFACTS_DIR); } }); if (!filteredMap.isEmpty()) { final AgentRunningBuild build = myTracker.getCurrentBuild(); final String pathPrefix = getPathPrefix(build); final S3FileUploader fileUploader = getFileUploader(build); myArtifacts.addAll(fileUploader.publishFiles(build, pathPrefix, filteredMap)); publishArtifactsList(build); } return filteredMap.size(); }
@Nullable private PathPatternFilter.PathNode getChild(@NotNull String path, @NotNull List<PathPatternFilter.PathNode> children) { return CollectionsUtil.findFirst(children, data -> path.equals(data.getPath())); }
private void publishArtifactsList(AgentRunningBuild build) { if (!myArtifacts.isEmpty()) { final String pathPrefix = getPathPrefix(build); try { myHelper.publishArtifactList(myArtifacts, CollectionsUtil.asMap(S3_PATH_PREFIX_ATTR, pathPrefix)); } catch (IOException e) { build.getBuildLogger().error(ERROR_PUBLISHING_ARTIFACTS_LIST + ": " + e.getMessage()); LOG.warnAndDebugDetails(ERROR_PUBLISHING_ARTIFACTS_LIST + "for build " + LogUtil.describe(build), e); } } }
final List<Callable<Void>> uploadTasks = CollectionsUtil.convertAndFilterNulls(filesToPublish.keySet(), new Converter<Callable<Void>, File>() { @Override public Callable<Void> createFrom(@NotNull final File file) {
@NotNull public List<String> filterPaths(@NotNull List<String> paths) { if (isIncludeAll()) return paths; final Collection<PathNode> files = AntPatternTreeMatcher.scan(createPathTree(paths), myIncludePatterns, myExcludePatterns, AntPatternTreeMatcher.ScanOption.LEAFS_ONLY); return CollectionsUtil.convertCollection(files, PathNode::getPath); }