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

Method sendChangesToUpstream

pkg/devspace/sync/sync.go:372–402  ·  view source on GitHub ↗
(changes []*FileInformation, remove bool)

Source from the content-addressed store, hash-verified

370}
371
372func (s *Sync) sendChangesToUpstream(changes []*FileInformation, remove bool) {
373 for j := 0; j < len(changes); j += initialUpstreamBatchSize {
374 // Wait till upstream channel is empty
375 for len(s.upstream.events) > 0 {
376 time.Sleep(time.Millisecond * 500)
377 }
378
379 // Now we send them to upstream
380 sendBatch := make([]*FileInformation, 0, initialUpstreamBatchSize)
381 s.fileIndex.fileMapMutex.Lock()
382
383 for i := j; i < (j+initialUpstreamBatchSize) && i < len(changes); i++ {
384 if remove {
385 sendBatch = append(sendBatch, changes[i])
386 } else if s.fileIndex.fileMap[changes[i].Name] == nil || !equalFilePermissions(changes[i].Mode, s.fileIndex.fileMap[changes[i].Name].Mode) || changes[i].Mtime != s.fileIndex.fileMap[changes[i].Name].Mtime || changes[i].Size != s.fileIndex.fileMap[changes[i].Name].Size {
387 sendBatch = append(sendBatch, changes[i])
388 }
389 }
390
391 s.fileIndex.fileMapMutex.Unlock()
392
393 // We do this out of the fileIndex lock, because otherwise this could cause a deadlock
394 // (Upstream waits in getfileInformationFromEvent and upstream.events buffer is full)
395 for i := 0; i < len(sendBatch); i++ {
396 s.upstream.isBusyMutex.Lock()
397 s.upstream.isBusy = true
398 s.upstream.events <- sendBatch[i]
399 s.upstream.isBusyMutex.Unlock()
400 }
401 }
402}
403
404func equalFilePermissions(mode os.FileMode, mode2 os.FileMode) bool {
405 if runtime.GOOS != "linux" && runtime.GOOS != "darwin" {

Callers

nothing calls this directly

Calls 3

equalFilePermissionsFunction · 0.85
LockMethod · 0.80
UnlockMethod · 0.80

Tested by

no test coverage detected