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

Method initialSync

pkg/devspace/sync/sync.go:277–370  ·  view source on GitHub ↗
(onInitUploadDone chan struct{}, onInitDownloadDone chan struct{})

Source from the content-addressed store, hash-verified

275}
276
277func (s *Sync) initialSync(onInitUploadDone chan struct{}, onInitDownloadDone chan struct{}) error {
278 initialSync := newInitialSyncer(&initialSyncOptions{
279 LocalPath: s.LocalPath,
280 Strategy: s.Options.InitialSync,
281 CompareBy: s.Options.InitialSyncCompareBy,
282
283 IgnoreMatcher: s.ignoreMatcher,
284 DownloadIgnoreMatcher: s.downloadIgnoreMatcher,
285 UploadIgnoreMatcher: s.uploadIgnoreMatcher,
286
287 UpstreamDisabled: s.Options.UpstreamDisabled,
288 DownstreamDisabled: s.Options.DownstreamDisabled,
289 FileIndex: s.fileIndex,
290
291 ApplyRemote: s.sendChangesToUpstream,
292 ApplyLocal: s.downstream.applyChanges,
293 AddSymlink: s.upstream.AddSymlink,
294 Log: s.log,
295
296 UpstreamDone: func() {
297 if !s.Options.UpstreamDisabled {
298 for s.upstream.IsBusy() {
299 time.Sleep(time.Millisecond * 100)
300 }
301 }
302
303 // signal upstream that initial sync is done
304 s.upstream.initialSyncCompletedMutex.Lock()
305 s.upstream.initialSyncCompleted = true
306 s.upstream.initialSyncCompletedMutex.Unlock()
307
308 // wait until initial sync commands were executed
309 if !s.Options.UpstreamDisabled {
310 for s.upstream.IsInitialSyncing() {
311 time.Sleep(time.Millisecond * 100)
312 }
313 }
314
315 if onInitUploadDone != nil {
316 if s.Options.InitialSync == latest.InitialSyncStrategyDisabled {
317 s.log.Info("Upstream - Initial sync disabled")
318 } else {
319 s.log.Info("Upstream - Initial sync completed")
320 }
321 close(onInitUploadDone)
322 }
323 },
324 DownstreamDone: func() {
325 if onInitDownloadDone != nil {
326 if s.Options.InitialSync == latest.InitialSyncStrategyDisabled {
327 s.log.Info("Downstream - Initial sync disabled")
328 } else {
329 s.log.Info("Downstream - Initial sync completed")
330 }
331 close(onInitDownloadDone)
332 }
333 },
334 })

Callers 2

mainLoopMethod · 0.95
TestInitialSyncFunction · 0.80

Calls 12

newInitialSyncerFunction · 0.85
closeFunction · 0.85
IsBusyMethod · 0.80
LockMethod · 0.80
UnlockMethod · 0.80
IsInitialSyncingMethod · 0.80
populateFileMapMethod · 0.80
CalculateLocalStateMethod · 0.80
MatchesMethod · 0.65
RunMethod · 0.65
InfoMethod · 0.45
DebugfMethod · 0.45

Tested by 1

TestInitialSyncFunction · 0.64