notes and base work
This commit is contained in:
parent
84c260c7f1
commit
bd70060729
2
NOTES.md
2
NOTES.md
|
@ -1,4 +1,4 @@
|
||||||
|
|
||||||
## things to watch for
|
## things to watch for
|
||||||
* ownership and info on shared inodes
|
* shared inodes share all attributes too
|
||||||
|
|
||||||
|
|
14
base/base.go
14
base/base.go
|
@ -7,12 +7,13 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func NewBase(path string, hashName string) (*Base, error) {
|
func NewBase(path string, hashName string) (*Base, error) {
|
||||||
for _, p := range []string{"dedup/blobs" + hashName, "dedup/state"} {
|
root := filepath.Join(path, "dedup")
|
||||||
if err := os.MkdirAll(filepath.Join(path, p), 0755); err != nil {
|
for _, p := range []string{"blobs/" + hashName, "state"} {
|
||||||
|
if err := os.MkdirAll(filepath.Join(root, p), 0755); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return &Base{Path: path, HashName: hashName}, nil
|
return &Base{Path: root, HashName: hashName}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
type Base struct {
|
type Base struct {
|
||||||
|
@ -20,6 +21,13 @@ type Base struct {
|
||||||
HashName string
|
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
|
// GetBlob store the content from src, for the sum and hashType
|
||||||
func (b Base) GetBlob(sum string) (io.Reader, error) {
|
func (b Base) GetBlob(sum string) (io.Reader, error) {
|
||||||
// XXX
|
// XXX
|
||||||
|
|
|
@ -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)
|
||||||
|
}
|
||||||
|
}
|
2
main.go
2
main.go
|
@ -38,9 +38,7 @@ func main() {
|
||||||
var (
|
var (
|
||||||
hash = cryptomap.DetermineHash(*flCipher)
|
hash = cryptomap.DetermineHash(*flCipher)
|
||||||
//infos = []*file.FileHashInfo{}
|
//infos = []*file.FileHashInfo{}
|
||||||
//mu = sync.Mutex{}
|
|
||||||
//results := make(chan file.FileHashInfo, 2)
|
//results := make(chan file.FileHashInfo, 2)
|
||||||
//wg := sync.WaitGroup{}
|
|
||||||
)
|
)
|
||||||
|
|
||||||
for _, arg := range flag.Args() {
|
for _, arg := range flag.Args() {
|
||||||
|
|
Loading…
Reference in New Issue