// Return the tarball path base on the supplied integrity.
// integrity - A sha512 or sha1 of the dependency tarball that was unpacked in node_modules (https://w3c.github.io/webappsec-subresource-integrity/).
Return the tarball path base on the supplied integrity.
integrity - A sha512 or sha1 of the dependency tarball that was unpacked in node_modules .
// Return the tarball path base on the supplied integrity . // integrity - A sha512 or sha1 of the dependency tarball that was unpacked in node_modules ( https : // w3c . github . io / webappsec - subresource - integrity / ) .
func (c *cacache) GetTarball(integrity string) (string, error) {
	hashAlgorithms, hash, err := integrityToSha(integrity)
	if err != nil {
		return "", err
	}
	if len(hash) < 5 {
		return "", errors.New("failed to calculate npm dependencies tree. Bad dependency integrity " + integrity)
	}
	 sha512-BaSE64Hex= ->
	 ~/.my-cache/content-v2/sha512/ba/da/55deadbeefc0ffee
	tarballPath := filepath.Join(c.cachePath, "content-v2", hashAlgorithms, hash[0:2], hash[2:4], hash[4:])
	found, err := utils.IsFileExists(tarballPath, false)
	if err != nil {
		return "", err
	}
	if !found {
		return "", errors.New("failed to locate dependency integrity '" + integrity + "' tarball at " + tarballPath)
	}
	return tarballPath, nil
}
func ( c * cacache ) GetTarball ( integrity string ) ( string , error ) { hashAlgorithms , hash , err := integrityToSha ( integrity ) if err != nil { return " " , err } if len ( hash ) < 5 { return " " , errors . New ( " " + integrity ) } tarballPath := filepath . Join ( c . cachePath , " " , hashAlgorithms , hash [ 0 : 2 ] , hash [ 2 : 4 ] , hash [ 4 : ] ) found , err := utils . IsFileExists ( tarballPath , false ) if err != nil { return " " , err } if ! found { return " " , errors . New ( " " + integrity + " " + tarballPath ) } return tarballPath , nil }
Return the tarball path base on the supplied integrity.
Return the tarball path base on the supplied integrity .
// Current format of content file path: // // sha512-BaSE64Hex= -> // ~/.my-cache/content-v2/sha512/ba/da/55deadbeefc0ffee