mirror of
https://github.com/vbatts/dedupe-linker.git
synced 2025-07-29 13:30:30 +00:00
filling out base functionality
This commit is contained in:
parent
842fa03b61
commit
aa6273d315
3 changed files with 37 additions and 13 deletions
33
base/base.go
33
base/base.go
|
@ -1,24 +1,41 @@
|
|||
package base
|
||||
|
||||
import (
|
||||
"crypto"
|
||||
"io"
|
||||
"os"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
func InitVarBase(base string) error {
|
||||
for _, path := range []string{"dedup/blobs", "dedup/state"} {
|
||||
if err := os.MkdirAll(filepath.Join(base, path), 0755); err != nil {
|
||||
return err
|
||||
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
|
||||
}
|
||||
}
|
||||
return nil
|
||||
return &Base{Path: path, HashName: hashName}, nil
|
||||
}
|
||||
|
||||
type Base struct {
|
||||
Path string
|
||||
Path string
|
||||
HashName string
|
||||
}
|
||||
|
||||
func (b Base) HasBlob(hashType crypto.Hash, sum string) bool {
|
||||
// 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
|
||||
}
|
||||
|
||||
// HasBlob tests whether a blob with this sum exists
|
||||
func (b Base) HasBlob(sum string) bool {
|
||||
// XXX
|
||||
return true
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue