mirror of
https://github.com/restic/restic.git
synced 2024-12-23 08:16:36 +00:00
Add a lot of comments
This commit is contained in:
parent
c34aa72538
commit
eb1669a061
2 changed files with 12 additions and 2 deletions
|
@ -16,6 +16,7 @@ type MockBackend struct {
|
|||
LocationFn func() string
|
||||
}
|
||||
|
||||
// Close the backend.
|
||||
func (m *MockBackend) Close() error {
|
||||
if m.CloseFn == nil {
|
||||
return nil
|
||||
|
@ -24,6 +25,7 @@ func (m *MockBackend) Close() error {
|
|||
return m.CloseFn()
|
||||
}
|
||||
|
||||
// Location returns a location string.
|
||||
func (m *MockBackend) Location() string {
|
||||
if m.LocationFn == nil {
|
||||
return ""
|
||||
|
@ -32,6 +34,7 @@ func (m *MockBackend) Location() string {
|
|||
return m.LocationFn()
|
||||
}
|
||||
|
||||
// Load loads data from the backend.
|
||||
func (m *MockBackend) Load(h Handle, p []byte, off int64) (int, error) {
|
||||
if m.LoadFn == nil {
|
||||
return 0, errors.New("not implemented")
|
||||
|
@ -40,6 +43,7 @@ func (m *MockBackend) Load(h Handle, p []byte, off int64) (int, error) {
|
|||
return m.LoadFn(h, p, off)
|
||||
}
|
||||
|
||||
// Save data in the backend.
|
||||
func (m *MockBackend) Save(h Handle, p []byte) error {
|
||||
if m.SaveFn == nil {
|
||||
return errors.New("not implemented")
|
||||
|
@ -48,6 +52,7 @@ func (m *MockBackend) Save(h Handle, p []byte) error {
|
|||
return m.SaveFn(h, p)
|
||||
}
|
||||
|
||||
// Stat an object in the backend.
|
||||
func (m *MockBackend) Stat(h Handle) (BlobInfo, error) {
|
||||
if m.StatFn == nil {
|
||||
return BlobInfo{}, errors.New("not implemented")
|
||||
|
@ -56,6 +61,7 @@ func (m *MockBackend) Stat(h Handle) (BlobInfo, error) {
|
|||
return m.StatFn(h)
|
||||
}
|
||||
|
||||
// List items of type t.
|
||||
func (m *MockBackend) List(t Type, done <-chan struct{}) <-chan string {
|
||||
if m.ListFn == nil {
|
||||
ch := make(chan string)
|
||||
|
@ -66,6 +72,7 @@ func (m *MockBackend) List(t Type, done <-chan struct{}) <-chan string {
|
|||
return m.ListFn(t, done)
|
||||
}
|
||||
|
||||
// Remove data from the backend.
|
||||
func (m *MockBackend) Remove(t Type, name string) error {
|
||||
if m.RemoveFn == nil {
|
||||
return errors.New("not implemented")
|
||||
|
@ -74,6 +81,7 @@ func (m *MockBackend) Remove(t Type, name string) error {
|
|||
return m.RemoveFn(t, name)
|
||||
}
|
||||
|
||||
// Test for the existence of a specific item.
|
||||
func (m *MockBackend) Test(t Type, name string) (bool, error) {
|
||||
if m.TestFn == nil {
|
||||
return false, errors.New("not implemented")
|
||||
|
@ -82,6 +90,7 @@ func (m *MockBackend) Test(t Type, name string) (bool, error) {
|
|||
return m.TestFn(t, name)
|
||||
}
|
||||
|
||||
// Delete all data.
|
||||
func (m *MockBackend) Delete() error {
|
||||
if m.DeleteFn == nil {
|
||||
return errors.New("not implemented")
|
||||
|
|
|
@ -2,7 +2,7 @@ package backend
|
|||
|
||||
import "os"
|
||||
|
||||
// Default paths for file-based backends (e.g. local)
|
||||
// Paths contains the default paths for file-based backends (e.g. local).
|
||||
var Paths = struct {
|
||||
Data string
|
||||
Snapshots string
|
||||
|
@ -21,5 +21,6 @@ var Paths = struct {
|
|||
"config",
|
||||
}
|
||||
|
||||
// Default modes for file-based backends
|
||||
// Modes holds the default modes for directories and files for file-based
|
||||
// backends.
|
||||
var Modes = struct{ Dir, File os.FileMode }{0700, 0600}
|
||||
|
|
Loading…
Reference in a new issue