buildPoolPath generates pool path based on file checksum
(filename string, checksums *utils.ChecksumInfo)
| 61 | |
| 62 | // buildPoolPath generates pool path based on file checksum |
| 63 | func (pool *PackagePool) buildPoolPath(filename string, checksums *utils.ChecksumInfo) (string, error) { |
| 64 | filename = filepath.Base(filename) |
| 65 | if filename == "." || filename == "/" { |
| 66 | return "", fmt.Errorf("filename %s is invalid", filename) |
| 67 | } |
| 68 | |
| 69 | hash := checksums.SHA256 |
| 70 | |
| 71 | if len(hash) < 4 { |
| 72 | // this should never happen in real life |
| 73 | return "", fmt.Errorf("unable to compute pool location for filename %v, SHA256 is missing", filename) |
| 74 | } |
| 75 | |
| 76 | return filepath.Join(hash[0:2], hash[2:4], hash[4:32]+"_"+filename), nil |
| 77 | } |
| 78 | |
| 79 | // FilepathList returns file paths of all the files in the pool |
| 80 | func (pool *PackagePool) FilepathList(progress aptly.Progress) ([]string, error) { |
no outgoing calls