diff --git a/backend/interface.go b/backend/interface.go index d3787d59b..b45f962f0 100644 --- a/backend/interface.go +++ b/backend/interface.go @@ -5,7 +5,7 @@ import "errors" type Type string const ( - Blob Type = "blob" + Data Type = "data" Key = "key" Lock = "lock" Snapshot = "snapshot" diff --git a/backend/local.go b/backend/local.go index ec41073ba..9ba203fbc 100644 --- a/backend/local.go +++ b/backend/local.go @@ -14,7 +14,7 @@ import ( const ( dirMode = 0700 - blobPath = "blobs" + dataPath = "data" snapshotPath = "snapshots" treePath = "trees" lockPath = "locks" @@ -32,7 +32,7 @@ type Local struct { func OpenLocal(dir string) (*Local, error) { items := []string{ dir, - filepath.Join(dir, blobPath), + filepath.Join(dir, dataPath), filepath.Join(dir, snapshotPath), filepath.Join(dir, treePath), filepath.Join(dir, lockPath), @@ -83,7 +83,7 @@ func CreateLocal(dir string) (*Local, error) { versionFile := filepath.Join(dir, versionFileName) dirs := []string{ dir, - filepath.Join(dir, blobPath), + filepath.Join(dir, dataPath), filepath.Join(dir, snapshotPath), filepath.Join(dir, treePath), filepath.Join(dir, lockPath), @@ -104,7 +104,7 @@ func CreateLocal(dir string) (*Local, error) { } } - // create paths for blobs, refs and temp + // create paths for data, refs and temp for _, d := range dirs { err := os.MkdirAll(d, dirMode) if err != nil { @@ -152,8 +152,8 @@ func (b *Local) renameFile(file *os.File, t Type, id ID) error { func (b *Local) dir(t Type) string { var n string switch t { - case Blob: - n = blobPath + case Data: + n = dataPath case Snapshot: n = snapshotPath case Tree: diff --git a/backend/local_test.go b/backend/local_test.go index 938506890..056ba916f 100644 --- a/backend/local_test.go +++ b/backend/local_test.go @@ -45,7 +45,7 @@ func teardownBackend(t *testing.T, b *backend.Local) { } func testBackend(b backend.Server, t *testing.T) { - for _, tpe := range []backend.Type{backend.Blob, backend.Key, backend.Lock, backend.Snapshot, backend.Tree} { + for _, tpe := range []backend.Type{backend.Data, backend.Key, backend.Lock, backend.Snapshot, backend.Tree} { // detect non-existing files for _, test := range TestStrings { id, err := backend.ParseID(test.id) diff --git a/backend/sftp.go b/backend/sftp.go index 1e11c2fd5..ff5774295 100644 --- a/backend/sftp.go +++ b/backend/sftp.go @@ -19,15 +19,6 @@ import ( ) const ( - // dirMode = 0700 - // blobPath = "blobs" - // snapshotPath = "snapshots" - // treePath = "trees" - // lockPath = "locks" - // keyPath = "keys" - // tempPath = "tmp" - // versionFileName = "version" - tempfileRandomSuffixLength = 10 ) @@ -83,7 +74,7 @@ func OpenSFTP(dir string, program string, args ...string) (*SFTP, error) { // test if all necessary dirs and files are there items := []string{ dir, - filepath.Join(dir, blobPath), + filepath.Join(dir, dataPath), filepath.Join(dir, snapshotPath), filepath.Join(dir, treePath), filepath.Join(dir, lockPath), @@ -139,7 +130,7 @@ func CreateSFTP(dir string, program string, args ...string) (*SFTP, error) { versionFile := filepath.Join(dir, versionFileName) dirs := []string{ dir, - filepath.Join(dir, blobPath), + filepath.Join(dir, dataPath), filepath.Join(dir, snapshotPath), filepath.Join(dir, treePath), filepath.Join(dir, lockPath), @@ -160,7 +151,7 @@ func CreateSFTP(dir string, program string, args ...string) (*SFTP, error) { } } - // create paths for blobs, refs and temp + // create paths for data, refs and temp blobs for _, d := range dirs { // TODO: implement client.MkdirAll() and set mode to dirMode _, err = sftp.c.Lstat(d) @@ -241,8 +232,8 @@ func (r *SFTP) renameFile(filename string, t Type, id ID) error { func (r *SFTP) dir(t Type) string { var n string switch t { - case Blob: - n = blobPath + case Data: + n = dataPath case Snapshot: n = snapshotPath case Tree: diff --git a/cmd/khepri/cmd_cat.go b/cmd/khepri/cmd_cat.go index 9a4c27291..0e3b67056 100644 --- a/cmd/khepri/cmd_cat.go +++ b/cmd/khepri/cmd_cat.go @@ -35,14 +35,14 @@ func commandCat(be backend.Server, key *khepri.Key, args []string) error { switch tpe { case "blob": // try id - data, err := ch.Load(backend.Blob, id) + data, err := ch.Load(backend.Data, id) if err == nil { _, err = os.Stdout.Write(data) return err } // try storage id - buf, err := be.Get(backend.Blob, id) + buf, err := be.Get(backend.Data, id) if err != nil { return err } diff --git a/cmd/khepri/cmd_list.go b/cmd/khepri/cmd_list.go index 46cf6bcc0..a58eee254 100644 --- a/cmd/khepri/cmd_list.go +++ b/cmd/khepri/cmd_list.go @@ -10,7 +10,7 @@ import ( func commandList(be backend.Server, key *khepri.Key, args []string) error { if len(args) != 1 { - return errors.New("usage: list [blobs|trees|snapshots|keys|locks]") + return errors.New("usage: list [data|trees|snapshots|keys|locks]") } var ( @@ -18,8 +18,8 @@ func commandList(be backend.Server, key *khepri.Key, args []string) error { each func(backend.Server, backend.Type, func(backend.ID, []byte, error)) error = backend.Each ) switch args[0] { - case "blobs": - t = backend.Blob + case "data": + t = backend.Data each = key.Each case "trees": t = backend.Tree @@ -35,7 +35,7 @@ func commandList(be backend.Server, key *khepri.Key, args []string) error { } return each(be, t, func(id backend.ID, data []byte, err error) { - if t == backend.Blob || t == backend.Tree { + if t == backend.Data || t == backend.Tree { fmt.Printf("%s %s\n", id, backend.Hash(data)) } else { fmt.Printf("%s\n", id) diff --git a/contenthandler.go b/contenthandler.go index 68b3f75f1..271df9b76 100644 --- a/contenthandler.go +++ b/contenthandler.go @@ -125,7 +125,7 @@ func (ch *ContentHandler) SaveFile(filename string, size uint) (Blobs, error) { return nil, err } - blob, err := ch.Save(backend.Blob, buf) + blob, err := ch.Save(backend.Data, buf) if err != nil { return nil, err } @@ -147,7 +147,7 @@ func (ch *ContentHandler) SaveFile(filename string, size uint) (Blobs, error) { return nil, err } - blob, err := ch.Save(backend.Blob, chunk.Data) + blob, err := ch.Save(backend.Data, chunk.Data) if err != nil { return nil, err } diff --git a/tree.go b/tree.go index ecc232814..ad5f64597 100644 --- a/tree.go +++ b/tree.go @@ -171,7 +171,7 @@ func (node *Node) CreateAt(ch *ContentHandler, path string) error { } for _, blobid := range node.Content { - buf, err := ch.Load(backend.Blob, blobid) + buf, err := ch.Load(backend.Data, blobid) if err != nil { return arrar.Annotate(err, "Load") }