@@ -51,7 +51,6 @@ type Cache struct {
51
51
// to share a cache directory (for example, if the directory were stored
52
52
// in a network file system). File locking is notoriously unreliable in
53
53
// network file systems and may not suffice to protect the cache.
54
- //
55
54
func Open (dir string ) (* Cache , error ) {
56
55
info , err := os .Stat (dir )
57
56
if err != nil {
@@ -159,7 +158,7 @@ func (c *Cache) get(id ActionID) (Entry, error) {
159
158
defer f .Close ()
160
159
entry := make ([]byte , entrySize + 1 ) // +1 to detect whether f is too long
161
160
if n , readErr := io .ReadFull (f , entry ); n != entrySize || readErr != io .ErrUnexpectedEOF {
162
- return failed (fmt .Errorf ("read %d/%d bytes from %s with error %s " , n , entrySize , fileName , readErr ))
161
+ return failed (fmt .Errorf ("read %d/%d bytes from %s with error %w " , n , entrySize , fileName , readErr ))
163
162
}
164
163
if entry [0 ] != 'v' || entry [1 ] != '1' || entry [2 ] != ' ' || entry [3 + hexSize ] != ' ' || entry [3 + hexSize + 1 + hexSize ] != ' ' || entry [3 + hexSize + 1 + hexSize + 1 + 20 ] != ' ' || entry [entrySize - 1 ] != '\n' {
165
164
return failed (fmt .Errorf ("bad data in %s" , fileName ))
@@ -181,15 +180,15 @@ func (c *Cache) get(id ActionID) (Entry, error) {
181
180
}
182
181
size , err := strconv .ParseInt (string (esize [i :]), 10 , 64 )
183
182
if err != nil || size < 0 {
184
- return failed (fmt .Errorf ("failed to parse esize int from %s with error %s " , fileName , err ))
183
+ return failed (fmt .Errorf ("failed to parse esize int from %s with error %w " , fileName , err ))
185
184
}
186
185
i = 0
187
186
for i < len (etime ) && etime [i ] == ' ' {
188
187
i ++
189
188
}
190
189
tm , err := strconv .ParseInt (string (etime [i :]), 10 , 64 )
191
190
if err != nil || tm < 0 {
192
- return failed (fmt .Errorf ("failed to parse etime int from %s with error %s " , fileName , err ))
191
+ return failed (fmt .Errorf ("failed to parse etime int from %s with error %w " , fileName , err ))
193
192
}
194
193
195
194
if err = c .used (fileName ); err != nil {
@@ -498,7 +497,7 @@ func (c *Cache) copyFile(file io.ReadSeeker, out OutputID, size int64) error {
498
497
return err
499
498
}
500
499
if n , wErr := h .Write (buf ); n != len (buf ) {
501
- return fmt .Errorf ("wrote to hash %d/%d bytes with error %s " , n , len (buf ), wErr )
500
+ return fmt .Errorf ("wrote to hash %d/%d bytes with error %w " , n , len (buf ), wErr )
502
501
}
503
502
504
503
sum := h .Sum (nil )
0 commit comments