dedupe-linker/base/base.go

42 lines
866 B
Go
Raw Normal View History

2014-09-12 20:10:10 +00:00
package base
import (
2014-09-16 21:12:52 +00:00
"io"
2014-09-12 20:10:10 +00:00
"os"
"path/filepath"
)
2014-09-16 21:12:52 +00:00
func NewBase(path string, hashName string) (*Base, error) {
for _, p := range []string{"dedup/blobs" + hashName, "dedup/state"} {
if err := os.MkdirAll(filepath.Join(path, p), 0755); err != nil {
return nil, err
2014-09-12 20:10:10 +00:00
}
}
2014-09-16 21:12:52 +00:00
return &Base{Path: path, HashName: hashName}, nil
2014-09-12 20:10:10 +00:00
}
type Base struct {
2014-09-16 21:12:52 +00:00
Path string
HashName string
}
// GetBlob store the content from src, for the sum and hashType
func (b Base) GetBlob(sum string) (io.Reader, error) {
// XXX
return nil, nil
}
// PutBlob store the content from src, for the sum and hashType
//
// we take the sum up front to avoid recalculation and tempfiles
func (b Base) PutBlob(sum string, src io.Reader) error {
// XXX
return nil
2014-09-12 20:10:10 +00:00
}
2014-09-16 21:12:52 +00:00
// HasBlob tests whether a blob with this sum exists
func (b Base) HasBlob(sum string) bool {
// XXX
2014-09-12 20:10:10 +00:00
return true
}