@@ -51,7 +51,6 @@ type Cache struct {
5151// to share a cache directory (for example, if the directory were stored
5252// in a network file system). File locking is notoriously unreliable in
5353// network file systems and may not suffice to protect the cache.
54- //
5554func Open (dir string ) (* Cache , error ) {
5655 info , err := os .Stat (dir )
5756 if err != nil {
@@ -159,7 +158,7 @@ func (c *Cache) get(id ActionID) (Entry, error) {
159158 defer f .Close ()
160159 entry := make ([]byte , entrySize + 1 ) // +1 to detect whether f is too long
161160 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 ))
163162 }
164163 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' {
165164 return failed (fmt .Errorf ("bad data in %s" , fileName ))
@@ -181,15 +180,15 @@ func (c *Cache) get(id ActionID) (Entry, error) {
181180 }
182181 size , err := strconv .ParseInt (string (esize [i :]), 10 , 64 )
183182 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 ))
185184 }
186185 i = 0
187186 for i < len (etime ) && etime [i ] == ' ' {
188187 i ++
189188 }
190189 tm , err := strconv .ParseInt (string (etime [i :]), 10 , 64 )
191190 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 ))
193192 }
194193
195194 if err = c .used (fileName ); err != nil {
@@ -498,7 +497,7 @@ func (c *Cache) copyFile(file io.ReadSeeker, out OutputID, size int64) error {
498497 return err
499498 }
500499 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 )
502501 }
503502
504503 sum := h .Sum (nil )
0 commit comments