mirror of
https://github.com/ceph/go-ceph
synced 2025-01-30 10:06:32 +00:00
ioctx: do not short-circuit read for empty slice
ioctx.read should contact the cluster even when its slice is empty so that errors like ENOENT can be reported. Signed-off-by: Noah Watkins <nwatkins@redhat.com>
This commit is contained in:
parent
c14a3857fa
commit
0a30725b59
@ -141,17 +141,18 @@ func (ioctx *IOContext) Append(oid string, data []byte) error {
|
||||
// Read reads up to len(data) bytes from the object with key oid starting at byte
|
||||
// offset offset. It returns the number of bytes read and an error, if any.
|
||||
func (ioctx *IOContext) Read(oid string, data []byte, offset uint64) (int, error) {
|
||||
if len(data) == 0 {
|
||||
return 0, nil
|
||||
}
|
||||
|
||||
c_oid := C.CString(oid)
|
||||
defer C.free(unsafe.Pointer(c_oid))
|
||||
|
||||
var buf *C.char
|
||||
if len(data) > 0 {
|
||||
buf = (*C.char)(unsafe.Pointer(&data[0]))
|
||||
}
|
||||
|
||||
ret := C.rados_read(
|
||||
ioctx.ioctx,
|
||||
c_oid,
|
||||
(*C.char)(unsafe.Pointer(&data[0])),
|
||||
buf,
|
||||
(C.size_t)(len(data)),
|
||||
(C.uint64_t)(offset))
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user