From e568818c0c7379b3717e26d92a429c7e499cf06d Mon Sep 17 00:00:00 2001 From: John Jacquay Date: Thu, 14 Jul 2016 11:53:19 -0400 Subject: [PATCH] Resolves #15 Added better error handling to differentiate between errors and empty meta collections --- lib/build/libgorods.a | Bin 115778 -> 115794 bytes lib/wrapper.c | 4 ++-- meta.go | 22 +++++++++++++++++----- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/lib/build/libgorods.a b/lib/build/libgorods.a index 3333752973d573efc5f3da07ddd6a79eda570590..b76255360cd5f22fbed6ff519c5d34240ab39741 100644 GIT binary patch delta 341 zcmX@q!G5WOeS#c|iG_j1Mx{&43Lu7pf}w$dArfh3W&-3HnwXoIOcr6$V?43hndPMl z^MTc$H|uN8=jT=^$}cZgNXswHOPPGZLUHmZi)I$T{Jhl3C6;=d=UblM&G=(-_SfT# zPbV9HGiN+HIs2PEe%So_=YKWE2h(3G zFfM0eV4gljkx`G)aQk6JMs`L<)9I&`7~?_0I?6y{pXt%cjQxxO(_bq?M153%qUqDC zRT!5uW=&UCWh`fG*gjj8(Vj`NnVA6$?&(8lZXm@9#2wQ=s{@rSn4Yb{sL!}#`)m!y G<+A}c<#^oy delta 327 zcmYj{Jxjw-6o!3oD-|3B5y3^$HkEYfM{MZ_6|YbSe}qsF1VM0BxSKc>92CxQ1qT-) zLKihi3UPALIU*v0=%#eFH6cU1wTlPN^PcmZDYmmoFSR5EwFBC(=j`kHgNsiR{d+u7b5O+% zi2+BKTt$mQMVA^s99tw5d*mvfP^frG4WDD0gwGl8(Z}~JdA@-a3YAvJfMbG0z?t8t z+h7^*b{Iqpc$T3Ci}_5RCy__ic}yY!TJK4AUdKt}EM;hdL~5 o$WjKo*mF7=a5m?$vA=pNjB--NxN0F|hI%6@3>0wTbPQOhzj#Y{NdN!< diff --git a/lib/wrapper.c b/lib/wrapper.c index 6ece602..fd5de08 100644 --- a/lib/wrapper.c +++ b/lib/wrapper.c @@ -916,8 +916,8 @@ int gorods_meta_collection(char *name, char *cwd, goRodsMetaResult_t* result, rc status = rcGenQuery(conn, &genQueryInp, &genQueryOut); if ( status == 0 ) { - *err = "None"; - return -1; + *err = "No rows found"; + return CAT_NO_ROWS_FOUND; } if ( status == CAT_NO_ROWS_FOUND ) { diff --git a/meta.go b/meta.go index 70c665a..1b7c8e5 100644 --- a/meta.go +++ b/meta.go @@ -132,7 +132,7 @@ func (mc *MetaCollection) init() error { // If MetaCollection hasn't been opened, do it! if len(mc.Metas) < 1 { if err := mc.ReadMeta(); err != nil { - //return err + return err } } @@ -160,18 +160,30 @@ func (mc *MetaCollection) ReadMeta() error { switch mc.Obj.GetType() { case DataObjType: - cwd := C.CString(mc.Obj.GetCol().Path) + cwdGo := mc.Obj.GetCol().Path + cwd := C.CString(cwdGo) + defer C.free(unsafe.Pointer(cwd)) if status := C.gorods_meta_dataobj(name, cwd, &metaResult, mc.Con.ccon, &err); status != 0 { - return newError(Fatal, fmt.Sprintf("iRods Get Meta Failed: %v, %v", cwd, C.GoString(err))) + if status == C.CAT_NO_ROWS_FOUND { + return nil + } else { + return newError(Fatal, fmt.Sprintf("iRods Get Meta Failed: %v, %v, %v", cwdGo, C.GoString(err), status)) + } } case CollectionType: - cwd := C.CString(filepath.Dir(mc.Obj.GetPath())) + cwdGo := filepath.Dir(mc.Obj.GetPath()) + cwd := C.CString(cwdGo) + defer C.free(unsafe.Pointer(cwd)) if status := C.gorods_meta_collection(name, cwd, &metaResult, mc.Con.ccon, &err); status != 0 { - return newError(Fatal, fmt.Sprintf("iRods Get Meta Failed: %v, %v", cwd, C.GoString(err))) + if status == C.CAT_NO_ROWS_FOUND { + return nil + } else { + return newError(Fatal, fmt.Sprintf("iRods Get Meta Failed: %v, %v, %v", cwdGo, C.GoString(err), status)) + } } case ResourceType: