Skip to content
This repository has been archived by the owner on Mar 21, 2023. It is now read-only.

Commit

Permalink
Resolves #15 Added better error handling to differentiate between err…
Browse files Browse the repository at this point in the history
…ors and empty meta collections
  • Loading branch information
John Jacquay committed Jul 14, 2016
1 parent f5f4e1f commit e568818
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
Binary file modified lib/build/libgorods.a
Binary file not shown.
4 changes: 2 additions & 2 deletions lib/wrapper.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) {
Expand Down
22 changes: 17 additions & 5 deletions meta.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

Expand Down Expand Up @@ -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:

Expand Down

0 comments on commit e568818

Please sign in to comment.