(onInitUploadDone chan struct{}, onInitDownloadDone chan struct{})
| 207 | } |
| 208 | |
| 209 | func (s *Sync) mainLoop(onInitUploadDone chan struct{}, onInitDownloadDone chan struct{}) { |
| 210 | s.log.Info("Start syncing") |
| 211 | |
| 212 | // Start upstream as early as possible |
| 213 | if !s.Options.UpstreamDisabled { |
| 214 | go s.startUpstream() |
| 215 | } |
| 216 | |
| 217 | // Start downstream and do initial sync |
| 218 | go func() { |
| 219 | err := s.initialSync(onInitUploadDone, onInitDownloadDone) |
| 220 | if err != nil { |
| 221 | s.Stop(errors.Wrap(err, "initial sync")) |
| 222 | return |
| 223 | } |
| 224 | |
| 225 | if !s.Options.DownstreamDisabled { |
| 226 | s.startDownstream() |
| 227 | s.Stop(nil) |
| 228 | } |
| 229 | }() |
| 230 | } |
| 231 | |
| 232 | func (s *Sync) startUpstream() { |
| 233 | defer s.Stop(nil) |
no test coverage detected