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 @@ -322,23 +322,27 @@ func (c *Base) GetClone(id string) (*models.Clone, error) {
322322 return nil , errors .New ("clone not found" )
323323 }
324324
325- if w .Session == nil {
325+ c .refreshCloneMetadata (w )
326+
327+ return w .Clone , nil
328+ }
329+
330+ func (c * Base ) refreshCloneMetadata (w * CloneWrapper ) {
331+ if w == nil || w .Session == nil || w .Clone == nil {
326332 // Not started yet.
327- return w . Clone , nil
333+ return
328334 }
329335
330336 sessionState , err := c .provision .GetSessionState (w .Session )
331337 if err != nil {
332338 // Session not ready yet.
333- log .Err (errors . Wrap ( err , "failed to get a session state" ))
339+ log .Err (fmt . Errorf ( "failed to get a session state: %w" , err ))
334340
335- return w . Clone , nil
341+ return
336342 }
337343
338344 w .Clone .Metadata .CloneDiffSize = sessionState .CloneDiffSize
339345 w .Clone .Metadata .LogicalSize = sessionState .LogicalReferenced
340-
341- return w .Clone , nil
342346}
343347
344348// UpdateClone updates clone.
@@ -493,6 +497,8 @@ func (c *Base) GetClones() []*models.Clone {
493497 cloneWrapper .Clone .Snapshot = snapshot
494498 }
495499
500+ c .refreshCloneMetadata (cloneWrapper )
501+
496502 clones = append (clones , cloneWrapper .Clone )
497503 }
498504 c .cloneMutex .RUnlock ()
You can’t perform that action at this time.
0 commit comments