Refactoring: use checksums instead of MD5 for pool/published

This is related to #506

As a first step, don't pass MD5 explicitly, pass checksum info object,
so that as a next step we can choose which hash to use.

There should be no functional changes so far.

Next step: stop returning explicit paths from public package pool.
This commit is contained in:
Andrey Smirnov
2017-04-01 00:09:34 +03:00
parent 675d35c7a1
commit 50cf2b49bd
16 changed files with 77 additions and 53 deletions
+5 -5
View File
@@ -13,15 +13,15 @@ import (
// PackagePool stores all the package files, deduplicating them.
type PackagePool interface {
// Path returns full path to package file in pool given any name and hash of file contents
Path(filename string, hashMD5 string) (string, error)
// RelativePath returns path relative to pool's root for package files given MD5 and original filename
RelativePath(filename string, hashMD5 string) (string, error)
Path(filename string, checksums utils.ChecksumInfo) (string, error)
// RelativePath returns path relative to pool's root for package files given checksums and original filename
RelativePath(filename string, checksums utils.ChecksumInfo) (string, error)
// FilepathList returns file paths of all the files in the pool
FilepathList(progress Progress) ([]string, error)
// Remove deletes file in package pool returns its size
Remove(path string) (size int64, err error)
// Import copies file into package pool
Import(path string, hashMD5 string) error
Import(path string, checksums utils.ChecksumInfo) error
}
// PublishedStorage is abstraction of filesystem storing all published repositories
@@ -35,7 +35,7 @@ type PublishedStorage interface {
// Remove removes single file under public path
Remove(path string) error
// LinkFromPool links package file from pool to dist's pool location
LinkFromPool(publishedDirectory string, sourcePool PackagePool, sourcePath, sourceMD5 string, force bool) error
LinkFromPool(publishedDirectory string, sourcePool PackagePool, sourcePath string, sourceChecksums utils.ChecksumInfo, force bool) error
// Filelist returns list of files under prefix
Filelist(prefix string) ([]string, error)
// RenameFile renames (moves) file