2
2
mirror of https://github.com/octoleo/restic.git synced 2024-12-25 20:11:06 +00:00

Rename backend subdir 'blobs' to 'data'

This commit is contained in:
Alexander Neumann 2014-11-16 13:22:19 +01:00
parent b403769ae8
commit 804cebde67
8 changed files with 22 additions and 31 deletions

View File

@ -5,7 +5,7 @@ import "errors"
type Type string
const (
Blob Type = "blob"
Data Type = "data"
Key = "key"
Lock = "lock"
Snapshot = "snapshot"

View File

@ -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:

View File

@ -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)

View File

@ -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:

View File

@ -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
}

View File

@ -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)

View File

@ -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
}

View File

@ -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")
}