File tree Expand file tree Collapse file tree 1 file changed +12
-6
lines changed Expand file tree Collapse file tree 1 file changed +12
-6
lines changed Original file line number Diff line number Diff line change @@ -325,23 +325,27 @@ func (c *Base) GetClone(id string) (*models.Clone, error) {
325325 return nil , errors .New ("clone not found" )
326326 }
327327
328- if w .Session == nil {
328+ c .refreshCloneMetadata (w )
329+
330+ return w .Clone , nil
331+ }
332+
333+ func (c * Base ) refreshCloneMetadata (w * CloneWrapper ) {
334+ if w == nil || w .Session == nil || w .Clone == nil {
329335 // Not started yet.
330- return w . Clone , nil
336+ return
331337 }
332338
333339 sessionState , err := c .provision .GetSessionState (w .Session )
334340 if err != nil {
335341 // Session not ready yet.
336- log .Err (errors . Wrap ( err , "failed to get a session state" ))
342+ log .Err (fmt . Errorf ( "failed to get a session state: %w" , err ))
337343
338- return w . Clone , nil
344+ return
339345 }
340346
341347 w .Clone .Metadata .CloneDiffSize = sessionState .CloneDiffSize
342348 w .Clone .Metadata .LogicalSize = sessionState .LogicalReferenced
343-
344- return w .Clone , nil
345349}
346350
347351// UpdateClone updates clone.
@@ -496,6 +500,8 @@ func (c *Base) GetClones() []*models.Clone {
496500 cloneWrapper .Clone .Snapshot = snapshot
497501 }
498502
503+ c .refreshCloneMetadata (cloneWrapper )
504+
499505 clones = append (clones , cloneWrapper .Clone )
500506 }
501507 c .cloneMutex .RUnlock ()
You can’t perform that action at this time.
0 commit comments