MCPcopy Index your code
hub / github.com/devspace-sh/devspace / applyChanges

Method applyChanges

pkg/devspace/sync/downstream.go:227–274  ·  view source on GitHub ↗
(changes []*remote.Change, force bool)

Source from the content-addressed store, hash-verified

225}
226
227func (d *downstream) applyChanges(changes []*remote.Change, force bool) error {
228 d.sync.log.Debugf("Downstream - Start applying %d changes", len(changes))
229 defer d.sync.log.Debugf("Downstream - Done applying changes")
230
231 var (
232 download = make([]*remote.Change, 0, len(changes)/2)
233 remove = make([]*remote.Change, 0, len(changes)/2)
234 )
235
236 // Skip if there are no changes
237 if len(changes) == 0 {
238 return nil
239 }
240
241 // determine what to delete and what to download
242 for _, change := range changes {
243 if change.ChangeType == remote.ChangeType_DELETE {
244 remove = append(remove, change)
245 } else {
246 download = append(download, change)
247 }
248 }
249
250 // Remove all files and folders that should be deleted first and we ignore errors
251 d.remove(remove, force)
252
253 // Extract downloaded archive
254 if len(download) > 0 {
255 for i := 0; i < syncRetries; i++ {
256 err := d.initDownload(download)
257 if err == nil {
258 break
259 } else if i+1 >= syncRetries {
260 return err
261 }
262
263 d.sync.log.Infof("Downstream - Retry download because of error: %v", err)
264
265 download = d.updateDownloadChanges(download)
266 if len(download) == 0 {
267 break
268 }
269 }
270 }
271
272 d.sync.log.Infof("Downstream - Successfully processed %d change(s)", len(changes))
273 return nil
274}
275
276func (d *downstream) updateDownloadChanges(download []*remote.Change) []*remote.Change {
277 d.sync.fileIndex.fileMapMutex.Lock()

Callers 1

mainLoopMethod · 0.95

Calls 5

removeMethod · 0.95
initDownloadMethod · 0.95
updateDownloadChangesMethod · 0.95
DebugfMethod · 0.45
InfofMethod · 0.45

Tested by

no test coverage detected