notes and base work

This commit is contained in:
Vincent Batts 2014-09-17 09:21:56 -04:00
parent 84c260c7f1
commit bd70060729
4 changed files with 23 additions and 6 deletions

View File

@ -1,4 +1,4 @@
## things to watch for
* ownership and info on shared inodes
* shared inodes share all attributes too

View File

@ -7,12 +7,13 @@ import (
)
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 {
root := filepath.Join(path, "dedup")
for _, p := range []string{"blobs/" + hashName, "state"} {
if err := os.MkdirAll(filepath.Join(root, p), 0755); err != nil {
return nil, err
}
}
return &Base{Path: path, HashName: hashName}, nil
return &Base{Path: root, HashName: hashName}, nil
}
type Base struct {
@ -20,6 +21,13 @@ type Base struct {
HashName string
}
func (b Base) blobPath(sum string) string {
if len(sum) < 3 {
return ""
}
return filepath.Join(b.Path, "blobs", b.HashName, sum[0:2], sum)
}
// GetBlob store the content from src, for the sum and hashType
func (b Base) GetBlob(sum string) (io.Reader, error) {
// XXX

11
base/base_test.go Normal file
View File

@ -0,0 +1,11 @@
package base
import "testing"
func TestSumPath(t *testing.T) {
expected := "/var/dedup/blobs/sha1/de/deadbeef"
b := Base{Path: "/var/dedup", HashName: "sha1"}
if bp := b.blobPath("deadbeef"); bp != expected {
t.Errorf("expected %q, got %q", expected, bp)
}
}

View File

@ -38,9 +38,7 @@ func main() {
var (
hash = cryptomap.DetermineHash(*flCipher)
//infos = []*file.FileHashInfo{}
//mu = sync.Mutex{}
//results := make(chan file.FileHashInfo, 2)
//wg := sync.WaitGroup{}
)
for _, arg := range flag.Args() {