mirror of
https://github.com/kopia/kopia.git
synced 2026-04-23 15:38:23 -04:00
fix(server): fixed server startup race condition (#1842)
This fixes a regression introduced in #1837
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user