@@ -40,6 +40,7 @@ import (
4040 "github.com/ActiveState/cli/pkg/platform/runtime/setup/implementations/camel"
4141 "github.com/ActiveState/cli/pkg/platform/runtime/store"
4242 "github.com/ActiveState/cli/pkg/platform/runtime/target"
43+ "github.com/ActiveState/cli/pkg/platform/runtime/validate"
4344 "github.com/ActiveState/cli/pkg/project"
4445 "github.com/faiface/mainthread"
4546 "github.com/gammazero/workerpool"
@@ -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 validate .Checksum (archivePath , a .Checksum )
609592}
610593
611594// downloadArtifact downloads an artifact and returns the local path to that artifact's archive.
0 commit comments