-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #54 from tonistiigi/metadata
persistent metadata helpers for snapshots
- Loading branch information
Showing
15 changed files
with
1,555 additions
and
193 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package cache | ||
|
||
import ( | ||
"github.com/boltdb/bolt" | ||
"github.com/moby/buildkit/cache/metadata" | ||
"github.com/pkg/errors" | ||
) | ||
|
||
// Fields to be added: | ||
// Size int64 | ||
// AccessTime int64 | ||
// Tags | ||
// Descr | ||
// CachePolicy | ||
|
||
const sizeUnknown int64 = -1 | ||
const keySize = "snapshot.size" | ||
|
||
func setSize(si *metadata.StorageItem, s int64) error { | ||
v, err := metadata.NewValue(s) | ||
if err != nil { | ||
return errors.Wrap(err, "failed to create size value") | ||
} | ||
si.Queue(func(b *bolt.Bucket) error { | ||
return si.SetValue(b, keySize, *v) | ||
}) | ||
return nil | ||
} | ||
|
||
func getSize(si *metadata.StorageItem) int64 { | ||
v := si.Get(keySize) | ||
if v == nil { | ||
return sizeUnknown | ||
} | ||
var size int64 | ||
if err := v.Unmarshal(&size); err != nil { | ||
return sizeUnknown | ||
} | ||
return size | ||
} |
Oops, something went wrong.