mirror of
https://github.com/octoleo/restic.git
synced 2025-01-11 10:18:10 +00:00
add debug logging to MemoryBackend
This commit is contained in:
parent
9cb4e14327
commit
538e5878a1
@ -6,6 +6,8 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"sort"
|
"sort"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
|
"github.com/restic/restic/debug"
|
||||||
)
|
)
|
||||||
|
|
||||||
type entry struct {
|
type entry struct {
|
||||||
@ -55,6 +57,8 @@ func NewMemoryBackend() *MemoryBackend {
|
|||||||
return memList(be, t, done)
|
return memList(be, t, done)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
debug.Log("MemoryBackend.New", "created new memory backend")
|
||||||
|
|
||||||
return be
|
return be
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,6 +78,8 @@ func memTest(be *MemoryBackend, t Type, name string) (bool, error) {
|
|||||||
be.m.Lock()
|
be.m.Lock()
|
||||||
defer be.m.Unlock()
|
defer be.m.Unlock()
|
||||||
|
|
||||||
|
debug.Log("MemoryBackend.Test", "test %v %v", t, name)
|
||||||
|
|
||||||
if _, ok := be.data[entry{t, name}]; ok {
|
if _, ok := be.data[entry{t, name}]; ok {
|
||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
@ -117,6 +123,8 @@ func memGet(be *MemoryBackend, t Type, name string) (io.ReadCloser, error) {
|
|||||||
be.m.Lock()
|
be.m.Lock()
|
||||||
defer be.m.Unlock()
|
defer be.m.Unlock()
|
||||||
|
|
||||||
|
debug.Log("MemoryBackend.Get", "get %v %v", t, name)
|
||||||
|
|
||||||
if _, ok := be.data[entry{t, name}]; !ok {
|
if _, ok := be.data[entry{t, name}]; !ok {
|
||||||
return nil, errors.New("no such data")
|
return nil, errors.New("no such data")
|
||||||
}
|
}
|
||||||
@ -128,6 +136,8 @@ func memGetReader(be *MemoryBackend, t Type, name string, offset, length uint) (
|
|||||||
be.m.Lock()
|
be.m.Lock()
|
||||||
defer be.m.Unlock()
|
defer be.m.Unlock()
|
||||||
|
|
||||||
|
debug.Log("MemoryBackend.GetReader", "get %v %v", t, name)
|
||||||
|
|
||||||
if _, ok := be.data[entry{t, name}]; !ok {
|
if _, ok := be.data[entry{t, name}]; !ok {
|
||||||
return nil, errors.New("no such data")
|
return nil, errors.New("no such data")
|
||||||
}
|
}
|
||||||
@ -152,6 +162,8 @@ func memRemove(be *MemoryBackend, t Type, name string) error {
|
|||||||
be.m.Lock()
|
be.m.Lock()
|
||||||
defer be.m.Unlock()
|
defer be.m.Unlock()
|
||||||
|
|
||||||
|
debug.Log("MemoryBackend.Remove", "get %v %v", t, name)
|
||||||
|
|
||||||
if _, ok := be.data[entry{t, name}]; !ok {
|
if _, ok := be.data[entry{t, name}]; !ok {
|
||||||
return errors.New("no such data")
|
return errors.New("no such data")
|
||||||
}
|
}
|
||||||
@ -177,6 +189,8 @@ func memList(be *MemoryBackend, t Type, done <-chan struct{}) <-chan string {
|
|||||||
|
|
||||||
sort.Strings(ids)
|
sort.Strings(ids)
|
||||||
|
|
||||||
|
debug.Log("MemoryBackend.List", "list %v: %v", t, ids)
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
defer close(ch)
|
defer close(ch)
|
||||||
for _, id := range ids {
|
for _, id := range ids {
|
||||||
|
Loading…
Reference in New Issue
Block a user