Class ChecksumReportPolicy

java.lang.Object
slash.navigation.download.ChecksumReportPolicy

public class ChecksumReportPolicy extends Object
Decides whether the checksum of a Download that failed may be reported to the catalog server as a new known-good build.

A failed download only carries a reportable checksum if the transfer provably completed and the failure came from validation: the response announced a Content-Length the written file matches exactly, and a Last-Modified the file still carries. That is the genuine "the upstream rebuilt the file and the catalog is stale" case the catalog wants to learn about. Anything else — a truncated transfer, a response without a Content-Length, a transport error, a different Last-Modified — describes content the server never announced, and reporting its checksum would pollute the catalog's known-good checksums (see GitHub #382).

Author:
Christian Pesch
  • Method Details

    • isReportableChecksum

      public static boolean isReportableChecksum(State state, Long announcedContentLength, Long actualContentLength, Long announcedLastModified, Long actualLastModified)
      Parameters:
      state - the terminal state of the download
      announcedContentLength - the Content-Length announced by the HTTP response, if any
      actualContentLength - the size of the file that was written
      announcedLastModified - the Last-Modified announced by the HTTP response, if any
      actualLastModified - the last-modified of the file that was written
      Returns:
      true iff this checksum is trustworthy enough to be reported to the server as a new known-good build