Skip to content

Commit 956b40d

Browse files
authored
set ready on file open as well as download complete (#13901)
fixes: #13897
1 parent a924d9d commit 956b40d

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

turbo/snapshotsync/snapshots.go

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -601,12 +601,11 @@ func (s *RoSnapshots) VisibleBlocksAvailable(t snaptype.Enum) uint64 {
601601
}
602602

603603
func (s *RoSnapshots) DownloadComplete() {
604-
if !s.SegmentsReady() {
605-
return
606-
}
607604
wasReady := s.downloadReady.Swap(true)
608605
if !wasReady {
609-
s.ready.set()
606+
if s.SegmentsReady() {
607+
s.ready.set()
608+
}
610609
}
611610
}
612611

@@ -987,7 +986,12 @@ func (s *RoSnapshots) InitSegments(fileNames []string) error {
987986
}
988987

989988
s.recalcVisibleFiles()
990-
s.segmentsReady.Store(true)
989+
wasReady := s.segmentsReady.Swap(true)
990+
if !wasReady {
991+
if s.downloadReady.Load() {
992+
s.ready.set()
993+
}
994+
}
991995

992996
return nil
993997
}
@@ -1152,7 +1156,12 @@ func (s *RoSnapshots) OpenFolder() error {
11521156
}
11531157

11541158
s.recalcVisibleFiles()
1155-
s.segmentsReady.Store(true)
1159+
wasReady := s.segmentsReady.Swap(true)
1160+
if !wasReady {
1161+
if s.downloadReady.Load() {
1162+
s.ready.set()
1163+
}
1164+
}
11561165
return nil
11571166
}
11581167

0 commit comments

Comments
 (0)