This commit is contained in:
mr 2024-12-02 16:26:44 +01:00
parent 9a2ed2351d
commit e2ddd7e4e6

View File

@ -425,19 +425,15 @@ func (r *Request) StoreOne(object map[string]interface{}) (data LibData) {
* @param c ...*tools.HTTPCaller * @param c ...*tools.HTTPCaller
* @return data LibData * @return data LibData
*/ */
func (r *Request) CopyOne(collection LibDataEnum, object map[string]interface{}, peerID string, groups []string, c ...*tools.HTTPCaller) (data LibData) { func (r *Request) CopyOne(object map[string]interface{}) (data LibData) {
defer func() { // recover the panic defer func() { // recover the panic
if r := recover(); r != nil { if r := recover(); r != nil {
tools.UncatchedError = append(tools.UncatchedError, errors.New("Panic recovered in CopyOne : "+fmt.Sprintf("%v", r)+" - "+string(debug.Stack()))) tools.UncatchedError = append(tools.UncatchedError, errors.New("Panic recovered in CopyOne : "+fmt.Sprintf("%v", r)+" - "+string(debug.Stack())))
data = LibData{Data: nil, Code: 500, Err: "Panic recovered in UpdateOne : " + fmt.Sprintf("%v", r) + " - " + string(debug.Stack())} data = LibData{Data: nil, Code: 500, Err: "Panic recovered in UpdateOne : " + fmt.Sprintf("%v", r) + " - " + string(debug.Stack())}
} }
}() }()
var caller *tools.HTTPCaller // define the caller model := models.Model(r.collection.EnumIndex())
if len(c) > 0 { d, code, err := model.GetAccessor(r.peerID, r.groups, r.caller).CopyOne(model.Deserialize(object, model))
caller = c[0]
}
model := models.Model(collection.EnumIndex())
d, code, err := model.GetAccessor(peerID, groups, caller).CopyOne(model.Deserialize(object, model))
if err != nil { if err != nil {
data = LibData{Data: d, Code: code, Err: err.Error()} data = LibData{Data: d, Code: code, Err: err.Error()}
return return