@@ -31,6 +31,7 @@ import (
3131 apimodel "github.com/ActiveState/cli/pkg/platform/model"
3232 "github.com/ActiveState/cli/pkg/platform/runtime/artifact"
3333 "github.com/ActiveState/cli/pkg/platform/runtime/artifactcache"
34+ "github.com/ActiveState/cli/pkg/platform/runtime/artifactvalidator"
3435 "github.com/ActiveState/cli/pkg/platform/runtime/envdef"
3536 "github.com/ActiveState/cli/pkg/platform/runtime/executor"
3637 "github.com/ActiveState/cli/pkg/platform/runtime/model"
@@ -587,25 +588,7 @@ func (s *Setup) downloadArtifactWithProgress(unsignedURI string, targetFile stri
587588// verifyArtifact verifies the checksum of the downloaded artifact matches the checksum given by the
588589// platform, and returns an error if the verification fails.
589590func (s * Setup ) verifyArtifact (archivePath string , a artifact.ArtifactDownload ) error {
590- if a .Checksum != "" {
591- logging .Debug ("Validating checksum for %s" , archivePath )
592- } else {
593- logging .Debug ("Skipping checksum validation for %s because the Platform did not provide a checksum to validate against." )
594- return nil
595- }
596-
597- checksum , err := fileutils .Sha256Hash (archivePath )
598- if err != nil {
599- return errs .Wrap (err , "Failed to compute checksum for " + a .ArtifactID .String ())
600- }
601-
602- if checksum != a .Checksum {
603- logging .Debug ("Checksum validation failed. Expected '%s', but was '%s'" , a .Checksum , checksum )
604- // Note: the artifact name will be reported higher up the chain
605- return locale .WrapError (err , "artifact_checksum_failed" , "Checksum validation failed" )
606- }
607-
608- return nil
591+ return artifactvalidator .ValidateChecksum (archivePath , a .Checksum )
609592}
610593
611594// downloadArtifact downloads an artifact and returns the local path to that artifact's archive.
0 commit comments