snapshot_scheduler.go RawHistoryFolder

1package daemon
2
3import (
4	"context"
5	"time"
6)
7
8func (d *Daemon) snapshotRepositorySaver(ctx context.Context) {
9	if d == nil {
10		return
11	}
12	timer := d.clock.NewTimer(24 * time.Hour)
13	defer timer.Stop()
14	for {
15		delay := d.scheduleEligibleRepositorySnapshots()
16		timer.Reset(delay)
17		select {
18		case <-ctx.Done():
19			return
20		case <-d.snapshotWake:
21		case <-timer.C():
22		}
23	}
24}
25
26func (d *Daemon) scheduleEligibleRepositorySnapshots() time.Duration {
27	d.mu.Lock()
28	sessions := d.sessionsSnapshotLocked()
29	d.mu.Unlock()
30	now := d.clock.Now()
31	for _, sess := range sessions {
32		if !sess.snapEligible.Load() || !sess.snapDirty.Load() {
33			continue
34		}
35		sess.snapshotMu.Lock()
36		due := !sess.snapshotPending && (sess.snapshotNextEligibleAt.IsZero() || !now.Before(sess.snapshotNextEligibleAt))
37		sess.snapshotMu.Unlock()
38		if due {
39			d.scheduleSnapshot(sess)
40		}
41	}
42
43	// Scheduling can synchronously fail or mark a capture pending, so inspect
44	// the final state to select the actual earliest timer deadline.
45	var next time.Time
46	for _, sess := range sessions {
47		if !sess.snapEligible.Load() || !sess.snapDirty.Load() {
48			continue
49		}
50		sess.snapshotMu.Lock()
51		eligibleAt := sess.snapshotNextEligibleAt
52		pending := sess.snapshotPending
53		sess.snapshotMu.Unlock()
54		if pending || eligibleAt.IsZero() {
55			continue
56		}
57		if next.IsZero() || eligibleAt.Before(next) {
58			next = eligibleAt
59		}
60	}
61	if next.IsZero() {
62		return 24 * time.Hour
63	}
64	if delay := next.Sub(now); delay > 0 {
65		return delay
66	}
67	return 0
68}

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 12

Tags 11

↑↓ moveenter openesc close