MCPcopy
hub / github.com/wavetermdev/waveterm / UpdateObject

Method UpdateObject

pkg/service/objectservice/objectservice.go:142–169  ·  view source on GitHub ↗
(uiContext waveobj.UIContext, waveObj waveobj.WaveObj, returnUpdates bool)

Source from the content-addressed store, hash-verified

140}
141
142func (svc *ObjectService) UpdateObject(uiContext waveobj.UIContext, waveObj waveobj.WaveObj, returnUpdates bool) (waveobj.UpdatesRtnType, error) {
143 ctx, cancelFn := context.WithTimeout(context.Background(), DefaultTimeout)
144 defer cancelFn()
145 ctx = waveobj.ContextWithUpdates(ctx)
146 if waveObj == nil {
147 return nil, fmt.Errorf("update wavobj is nil")
148 }
149 oref := waveobj.ORefFromWaveObj(waveObj)
150 found, err := wstore.DBExistsORef(ctx, *oref)
151 if err != nil {
152 return nil, fmt.Errorf("error getting object: %w", err)
153 }
154 if !found {
155 return nil, fmt.Errorf("object not found: %s", oref)
156 }
157 err = wstore.DBUpdate(ctx, waveObj)
158 if err != nil {
159 return nil, fmt.Errorf("error updating object: %w", err)
160 }
161 if (waveObj.GetOType() == waveobj.OType_Workspace) && (waveObj.(*waveobj.Workspace).Name != "") {
162 wps.Broker.Publish(wps.WaveEvent{
163 Event: wps.Event_WorkspaceUpdate})
164 }
165 if returnUpdates {
166 return waveobj.ContextGetUpdatesRtn(ctx), nil
167 }
168 return nil, nil
169}

Callers

nothing calls this directly

Calls 7

ContextWithUpdatesFunction · 0.92
ORefFromWaveObjFunction · 0.92
DBExistsORefFunction · 0.92
DBUpdateFunction · 0.92
ContextGetUpdatesRtnFunction · 0.92
PublishMethod · 0.80
GetOTypeMethod · 0.65

Tested by

no test coverage detected