2
2
mirror of https://github.com/octoleo/restic.git synced 2024-12-01 09:13:56 +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 type Type string
const ( const (
Blob Type = "blob" Data Type = "data"
Key = "key" Key = "key"
Lock = "lock" Lock = "lock"
Snapshot = "snapshot" Snapshot = "snapshot"

View File

@ -14,7 +14,7 @@ import (
const ( const (
dirMode = 0700 dirMode = 0700
blobPath = "blobs" dataPath = "data"
snapshotPath = "snapshots" snapshotPath = "snapshots"
treePath = "trees" treePath = "trees"
lockPath = "locks" lockPath = "locks"
@ -32,7 +32,7 @@ type Local struct {
func OpenLocal(dir string) (*Local, error) { func OpenLocal(dir string) (*Local, error) {
items := []string{ items := []string{
dir, dir,
filepath.Join(dir, blobPath), filepath.Join(dir, dataPath),
filepath.Join(dir, snapshotPath), filepath.Join(dir, snapshotPath),
filepath.Join(dir, treePath), filepath.Join(dir, treePath),
filepath.Join(dir, lockPath), filepath.Join(dir, lockPath),
@ -83,7 +83,7 @@ func CreateLocal(dir string) (*Local, error) {
versionFile := filepath.Join(dir, versionFileName) versionFile := filepath.Join(dir, versionFileName)
dirs := []string{ dirs := []string{
dir, dir,
filepath.Join(dir, blobPath), filepath.Join(dir, dataPath),
filepath.Join(dir, snapshotPath), filepath.Join(dir, snapshotPath),
filepath.Join(dir, treePath), filepath.Join(dir, treePath),
filepath.Join(dir, lockPath), 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 { for _, d := range dirs {
err := os.MkdirAll(d, dirMode) err := os.MkdirAll(d, dirMode)
if err != nil { 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 { func (b *Local) dir(t Type) string {
var n string var n string
switch t { switch t {
case Blob: case Data:
n = blobPath n = dataPath
case Snapshot: case Snapshot:
n = snapshotPath n = snapshotPath
case Tree: case Tree:

View File

@ -45,7 +45,7 @@ func teardownBackend(t *testing.T, b *backend.Local) {
} }
func testBackend(b backend.Server, t *testing.T) { 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 // detect non-existing files
for _, test := range TestStrings { for _, test := range TestStrings {
id, err := backend.ParseID(test.id) id, err := backend.ParseID(test.id)

View File

@ -19,15 +19,6 @@ import (
) )
const ( const (
// dirMode = 0700
// blobPath = "blobs"
// snapshotPath = "snapshots"
// treePath = "trees"
// lockPath = "locks"
// keyPath = "keys"
// tempPath = "tmp"
// versionFileName = "version"
tempfileRandomSuffixLength = 10 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 // test if all necessary dirs and files are there
items := []string{ items := []string{
dir, dir,
filepath.Join(dir, blobPath), filepath.Join(dir, dataPath),
filepath.Join(dir, snapshotPath), filepath.Join(dir, snapshotPath),
filepath.Join(dir, treePath), filepath.Join(dir, treePath),
filepath.Join(dir, lockPath), filepath.Join(dir, lockPath),
@ -139,7 +130,7 @@ func CreateSFTP(dir string, program string, args ...string) (*SFTP, error) {
versionFile := filepath.Join(dir, versionFileName) versionFile := filepath.Join(dir, versionFileName)
dirs := []string{ dirs := []string{
dir, dir,
filepath.Join(dir, blobPath), filepath.Join(dir, dataPath),
filepath.Join(dir, snapshotPath), filepath.Join(dir, snapshotPath),
filepath.Join(dir, treePath), filepath.Join(dir, treePath),
filepath.Join(dir, lockPath), 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 { for _, d := range dirs {
// TODO: implement client.MkdirAll() and set mode to dirMode // TODO: implement client.MkdirAll() and set mode to dirMode
_, err = sftp.c.Lstat(d) _, 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 { func (r *SFTP) dir(t Type) string {
var n string var n string
switch t { switch t {
case Blob: case Data:
n = blobPath n = dataPath
case Snapshot: case Snapshot:
n = snapshotPath n = snapshotPath
case Tree: case Tree:

View File

@ -35,14 +35,14 @@ func commandCat(be backend.Server, key *khepri.Key, args []string) error {
switch tpe { switch tpe {
case "blob": case "blob":
// try id // try id
data, err := ch.Load(backend.Blob, id) data, err := ch.Load(backend.Data, id)
if err == nil { if err == nil {
_, err = os.Stdout.Write(data) _, err = os.Stdout.Write(data)
return err return err
} }
// try storage id // try storage id
buf, err := be.Get(backend.Blob, id) buf, err := be.Get(backend.Data, id)
if err != nil { if err != nil {
return err return err
} }

View File

@ -10,7 +10,7 @@ import (
func commandList(be backend.Server, key *khepri.Key, args []string) error { func commandList(be backend.Server, key *khepri.Key, args []string) error {
if len(args) != 1 { 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 ( 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 each func(backend.Server, backend.Type, func(backend.ID, []byte, error)) error = backend.Each
) )
switch args[0] { switch args[0] {
case "blobs": case "data":
t = backend.Blob t = backend.Data
each = key.Each each = key.Each
case "trees": case "trees":
t = backend.Tree 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) { 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)) fmt.Printf("%s %s\n", id, backend.Hash(data))
} else { } else {
fmt.Printf("%s\n", id) fmt.Printf("%s\n", id)

View File

@ -125,7 +125,7 @@ func (ch *ContentHandler) SaveFile(filename string, size uint) (Blobs, error) {
return nil, err return nil, err
} }
blob, err := ch.Save(backend.Blob, buf) blob, err := ch.Save(backend.Data, buf)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -147,7 +147,7 @@ func (ch *ContentHandler) SaveFile(filename string, size uint) (Blobs, error) {
return nil, err return nil, err
} }
blob, err := ch.Save(backend.Blob, chunk.Data) blob, err := ch.Save(backend.Data, chunk.Data)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View File

@ -171,7 +171,7 @@ func (node *Node) CreateAt(ch *ContentHandler, path string) error {
} }
for _, blobid := range node.Content { for _, blobid := range node.Content {
buf, err := ch.Load(backend.Blob, blobid) buf, err := ch.Load(backend.Data, blobid)
if err != nil { if err != nil {
return arrar.Annotate(err, "Load") return arrar.Annotate(err, "Load")
} }