2
2
mirror of https://github.com/octoleo/restic.git synced 2024-12-27 12:42:49 +00:00

Fix MemoryBackend GetReader() method

This commit is contained in:
Alexander Neumann 2015-11-22 17:27:02 +01:00
parent 480054bc3a
commit 26697a0223

View File

@ -151,7 +151,7 @@ func memGetReader(be *MemoryBackend, t Type, name string, offset, length uint) (
name = ""
}
debug.Log("MemoryBackend.GetReader", "get %v %v", t, name)
debug.Log("MemoryBackend.GetReader", "get %v %v offset %v len %v", t, name, offset, length)
if _, ok := be.data[entry{t, name}]; !ok {
return nil, errors.New("no such data")
@ -164,11 +164,13 @@ func memGetReader(be *MemoryBackend, t Type, name string, offset, length uint) (
buf = buf[offset:]
if length > uint(len(buf)) {
length = uint(len(buf))
}
if length > 0 {
if length > uint(len(buf)) {
length = uint(len(buf))
}
buf = buf[:length]
buf = buf[:length]
}
return readCloser{bytes.NewReader(buf)}, nil
}