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

Commit

Permalink
Fixed bug when authenticating with tickets, parent collection isn't i…
Browse files Browse the repository at this point in the history
…nitialized
  • Loading branch information
jacquayj committed Feb 15, 2017
1 parent a6e3ede commit d525ffc
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
7 changes: 5 additions & 2 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,12 @@ func (cli *Client) OpenDataObject(path string, handler func(*DataObj, *Connectio

handler(obj, con)

if er := obj.col.Close(); er != nil {
return er
if obj.col != nil {
if er := obj.col.Close(); er != nil {
return er
}
}

if er := con.Disconnect(); er != nil {
return er
}
Expand Down
4 changes: 2 additions & 2 deletions collection.go
Original file line number Diff line number Diff line change
Expand Up @@ -1164,7 +1164,7 @@ func (col *Collection) ReadCollectionOpts(opts CollectionReadOpts) (CollectionRe
objTotal = int(col.cColHandle.dataObjSqlResult.totalRowCount)
objCnt = int(col.cColHandle.dataObjSqlResult.rowCnt)

col.add(initDataObj(&colEnt, col))
col.add(initDataObj(&colEnt, col, col.con))

}
col.con.ReturnCcon(ccon)
Expand Down Expand Up @@ -1212,7 +1212,7 @@ func (col *Collection) ReadCollection() error {
return er
}
} else {
col.add(initDataObj(&colEnt, col))
col.add(initDataObj(&colEnt, col, col.con))
}

}
Expand Down
13 changes: 7 additions & 6 deletions dataobj.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,13 @@ func (obj *DataObj) String() string {

// init function called from Collection.ReadCollection()
// We don't init() here or return errors here because it takes forever. Lazy loading is better in this case.
func initDataObj(data *C.collEnt_t, col *Collection) *DataObj {
func initDataObj(data *C.collEnt_t, col *Collection, con *Connection) *DataObj {

dataObj := new(DataObj)

dataObj.typ = DataObjType
dataObj.col = col
dataObj.con = dataObj.col.con
dataObj.con = con
dataObj.offset = 0
dataObj.name = C.GoString(data.dataName)
dataObj.path = C.GoString(data.collName) + "/" + dataObj.name
Expand All @@ -94,15 +94,15 @@ func initDataObj(data *C.collEnt_t, col *Collection) *DataObj {
dataObj.createTime = cTimeToTime(data.createTime)
dataObj.modifyTime = cTimeToTime(data.modifyTime)

if rsrcs, err := col.con.Resources(); err != nil {
if rsrcs, err := dataObj.con.Resources(); err != nil {
return nil
} else {
if r := rsrcs.FindByName(C.GoString(data.resource)); r != nil {
dataObj.resource = r
}
}

if usrs, err := col.con.Users(); err != nil {
if usrs, err := dataObj.con.Users(); err != nil {
return nil
} else {
if u := usrs.FindByName(dataObj.ownerName, dataObj.con); u != nil {
Expand Down Expand Up @@ -167,9 +167,10 @@ func getDataObj(startPath string, con *Connection) (*DataObj, error) {
}

if col, err := con.Collection(opts); err == nil {
return initDataObj(&cObjData, col), nil
return initDataObj(&cObjData, col, con), nil
} else {
return nil, err
// Couldn't open the parent collection...
return initDataObj(&cObjData, nil, con), nil
}

}
Expand Down

0 comments on commit d525ffc

Please sign in to comment.