public void checkArtifact()

in maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultUpdateCheckManager.java [138:209]


    public void checkArtifact(RepositorySystemSession session, UpdateCheck<Artifact, ArtifactTransferException> check) {
        requireNonNull(session, "session cannot be null");
        requireNonNull(check, "check cannot be null");
        final String updatePolicy = check.getArtifactPolicy();
        if (check.getLocalLastUpdated() != 0
                && !isUpdatedRequired(session, check.getLocalLastUpdated(), updatePolicy)) {
            LOGGER.debug("Skipped remote request for {}, locally installed artifact up-to-date", check.getItem());

            check.setRequired(false);
            return;
        }

        Artifact artifact = check.getItem();
        RemoteRepository repository = check.getRepository();

        Path artifactPath =
                requireNonNull(check.getPath(), String.format("The artifact '%s' has no file attached", artifact));

        boolean fileExists = check.isFileValid() && Files.exists(artifactPath);

        Path touchPath = getArtifactTouchFile(artifactPath);
        Properties props = read(touchPath);

        String updateKey = getUpdateKey(session, artifactPath, repository);
        String dataKey = getDataKey(repository);

        String error = getError(props, dataKey);

        long lastUpdated;
        if (error == null) {
            if (fileExists) {
                // last update was successful
                lastUpdated = pathProcessor.lastModified(artifactPath, 0L);
            } else {
                // this is the first attempt ever
                lastUpdated = TS_NEVER;
            }
        } else if (error.isEmpty()) {
            // artifact did not exist
            lastUpdated = getLastUpdated(props, dataKey);
        } else {
            // artifact could not be transferred
            String transferKey = getTransferKey(session, repository);
            lastUpdated = getLastUpdated(props, transferKey);
        }

        if (lastUpdated == TS_NEVER) {
            check.setRequired(true);
        } else if (isAlreadyUpdated(session, updateKey)) {
            LOGGER.debug("Skipped remote request for {}, already updated during this session", check.getItem());

            check.setRequired(false);
            if (error != null) {
                check.setException(newException(error, artifact, repository));
            }
        } else if (isUpdatedRequired(session, lastUpdated, updatePolicy)) {
            check.setRequired(true);
        } else if (fileExists) {
            LOGGER.debug("Skipped remote request for {}, locally cached artifact up-to-date", check.getItem());

            check.setRequired(false);
        } else {
            int errorPolicy = Utils.getPolicy(session, artifact, repository);
            int cacheFlag = getCacheFlag(error);
            if ((errorPolicy & cacheFlag) != 0) {
                check.setRequired(false);
                check.setException(newException(error, artifact, repository));
            } else {
                check.setRequired(true);
            }
        }
    }