@@ -22,6 +22,7 @@ import (
22
22
"github.com/pkg/errors"
23
23
"github.com/tonistiigi/fsutil"
24
24
fstypes "github.com/tonistiigi/fsutil/types"
25
+ "google.golang.org/protobuf/proto"
25
26
)
26
27
27
28
var errNotFound = errors .Errorf ("not found" )
@@ -241,7 +242,7 @@ func (cc *cacheContext) load() error {
241
242
}
242
243
243
244
var l CacheRecords
244
- if err := l .Unmarshal (dt ); err != nil {
245
+ if err := proto .Unmarshal (dt , & l ); err != nil {
245
246
return err
246
247
}
247
248
@@ -271,7 +272,7 @@ func (cc *cacheContext) save() error {
271
272
return false
272
273
})
273
274
274
- dt , err := l .Marshal ()
275
+ dt , err := proto .Marshal (& l )
275
276
if err != nil {
276
277
return err
277
278
}
@@ -311,7 +312,7 @@ func (cc *cacheContext) HandleChange(kind fsutil.ChangeKind, p string, fi os.Fil
311
312
if _ , ok := cc .node .Get ([]byte {0 }); ! ok {
312
313
cc .txn .Insert ([]byte {0 }, & CacheRecord {
313
314
Type : CacheRecordTypeDirHeader ,
314
- Digest : digest .FromBytes (nil ),
315
+ Digest : digest .FromBytes (nil ). String () ,
315
316
})
316
317
cc .txn .Insert ([]byte ("" ), & CacheRecord {
317
318
Type : CacheRecordTypeDir ,
@@ -363,16 +364,16 @@ func (cc *cacheContext) HandleChange(kind fsutil.ChangeKind, p string, fi os.Fil
363
364
k = append (k , 0 )
364
365
p += "/"
365
366
}
366
- cr .Digest = h .Digest ()
367
+ cr .Digest = h .Digest (). String ()
367
368
368
369
// if we receive a hardlink just use the digest of the source
369
370
// note that the source may be called later because data writing is async
370
371
if fi .Mode ()& os .ModeSymlink == 0 && stat .Linkname != "" {
371
372
ln := path .Join ("/" , filepath .ToSlash (stat .Linkname ))
372
373
v , ok := cc .txn .Get (convertPathToKey ([]byte (ln )))
373
374
if ok {
374
- cp := * v .(* CacheRecord )
375
- cr = & cp
375
+ cp := v .(* CacheRecord )
376
+ cr = cp
376
377
}
377
378
cc .linkMap [ln ] = append (cc .linkMap [ln ], k )
378
379
}
@@ -422,7 +423,7 @@ func (cc *cacheContext) Checksum(ctx context.Context, mountable cache.Mountable,
422
423
if err != nil {
423
424
return "" , err
424
425
}
425
- includedPaths [i ].record = & CacheRecord {Digest : dgst }
426
+ includedPaths [i ].record = & CacheRecord {Digest : dgst . String () }
426
427
}
427
428
}
428
429
}
@@ -431,7 +432,7 @@ func (cc *cacheContext) Checksum(ctx context.Context, mountable cache.Mountable,
431
432
}
432
433
433
434
if len (includedPaths ) == 1 && path .Base (p ) == path .Base (includedPaths [0 ].path ) {
434
- return includedPaths [0 ].record .Digest , nil
435
+ return digest . Digest ( includedPaths [0 ].record .Digest ) , nil
435
436
}
436
437
437
438
digester := digest .Canonical .Digester ()
@@ -464,7 +465,7 @@ func (cc *cacheContext) checksumFollow(ctx context.Context, m *mount, p string,
464
465
i ++
465
466
p = link
466
467
} else {
467
- return cr .Digest , nil
468
+ return digest . Digest ( cr .Digest ) , nil
468
469
}
469
470
}
470
471
}
@@ -957,7 +958,7 @@ func (cc *cacheContext) checksum(ctx context.Context, root *iradix.Node, txn *ir
957
958
}
958
959
959
960
cr2 := & CacheRecord {
960
- Digest : dgst ,
961
+ Digest : dgst . String () ,
961
962
Type : cr .Type ,
962
963
Linkname : cr .Linkname ,
963
964
}
0 commit comments