fix(server): fixed server startup race condition (#1842)

This fixes a regression introduced in #1837
This commit is contained in:
Jarek Kowalski
2022-03-20 22:21:03 -07:00
committed by GitHub
parent 3b45daf27a
commit 716ed71b59

View File

@@ -148,6 +148,12 @@ func (s *sourceManager) setUploader(u *snapshotfs.Uploader) {
}
func (s *sourceManager) start(ctx context.Context, rep repo.Repository) {
isLocal := rep.ClientOptions().Hostname == s.src.Host && !rep.ClientOptions().ReadOnly
go s.run(ctx, isLocal)
}
func (s *sourceManager) run(ctx context.Context, isLocal bool) {
// make sure we run in a detached context, which ignores outside cancelation and deadline.
ctx = ctxutil.Detach(ctx)
@@ -157,14 +163,12 @@ func (s *sourceManager) start(ctx context.Context, rep repo.Repository) {
s.wg.Add(1)
defer s.wg.Done()
if rep.ClientOptions().Hostname == s.src.Host && !rep.ClientOptions().ReadOnly {
if isLocal {
log(ctx).Debugf("starting local source manager for %v", s.src)
go s.runLocal(ctx)
s.runLocal(ctx)
} else {
log(ctx).Debugf("starting read-only source manager for %v", s.src)
go s.runReadOnly(ctx)
s.runReadOnly(ctx)
}
}