MCPcopy Create free account
hub / github.com/git-bug/git-bug / read

Method read

util/lamport/persisted_clock.go:72–105  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

70}
71
72func (pc *PersistedClock) read() error {
73 f, err := pc.root.Open(pc.filePath)
74 if os.IsNotExist(err) {
75 return ErrClockNotExist
76 }
77 if err != nil {
78 return err
79 }
80
81 content, err := io.ReadAll(f)
82 if err != nil {
83 _ = f.Close()
84 return err
85 }
86
87 err = f.Close()
88 if err != nil {
89 return err
90 }
91
92 var value uint64
93 n, err := fmt.Sscanf(string(content), "%d", &value)
94 if err != nil {
95 return err
96 }
97
98 if n != 1 {
99 return fmt.Errorf("could not read the clock")
100 }
101
102 pc.MemClock = NewMemClockWithTime(value)
103
104 return nil
105}
106
107func (pc *PersistedClock) Write() error {
108 data := []byte(fmt.Sprintf("%d", pc.counter))

Callers 1

LoadPersistedClockFunction · 0.95

Calls 5

NewMemClockWithTimeFunction · 0.85
ErrorfMethod · 0.80
ReadAllMethod · 0.65
CloseMethod · 0.65
OpenMethod · 0.45

Tested by

no test coverage detected