Skip to content

Commit

Permalink
add Validate description
Browse files Browse the repository at this point in the history
  • Loading branch information
mandelsoft committed Jun 12, 2024
1 parent ec42cb3 commit f5ecdd3
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pkg/blobaccess/blobaccess/other.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ func (a *annotatedBlobAccessView[T]) Source() T {
// It closes the wrapped access, if closed.
// If the wrapped data access does not need a close, the BlobAccess
// does not need a close, also.
// It adds the additional blob access metadata (mime, digest, and size).
// Digest and size can be set to unknown using the constants (BLOB_UNKNOWN_DIGEST
// and BLOB_UNKNOWN_SIZE).
func ForDataAccess[T bpi.DataAccess](digest digest.Digest, size int64, mimeType string, access T) AnnotatedBlobAccess[T] {
a := bpi.BaseAccessForDataAccessAndMeta(mimeType, access, digest, size)

Expand Down
8 changes: 8 additions & 0 deletions pkg/blobaccess/bpi/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,10 @@ func BaseAccessForDataAccess(mime string, acc DataAccess) BlobAccessBase {
}
}

// BaseAccessForDataAccessAndMeta provides a BlobAccessBase for a DataAccess
// adding the additional blob access metadata (mime, digest, and size).
// Digest and size can be set to unknown using the constants (BLOB_UNKNOWN_DIGEST
// and BLOB_UNKNOWN_SIZE).
func BaseAccessForDataAccessAndMeta(mime string, acc DataAccess, dig digest.Digest, size int64) BlobAccessBase {
return &closableBlobAccess{
blobAccess: blobAccess{mimeType: mime, _dataAccess: acc, digest: dig, size: size},
Expand Down Expand Up @@ -209,6 +213,10 @@ func ForStaticDataAccess(mime string, acc DataAccess) StaticBlobAccess {
}
}

// ForStaticDataAccessAndMeta provides a StaticBlobAccess for a DataAccess
// adding the additional blob access metadata (mime, digest, and size).
// Digest and size can be set to unknown using the constants (BLOB_UNKNOWN_DIGEST
// and BLOB_UNKNOWN_SIZE).
func ForStaticDataAccessAndMeta(mime string, acc DataAccess, dig digest.Digest, size int64) StaticBlobAccess {
return &staticBlobAccess{
blobAccess: blobAccess{mimeType: mime, _dataAccess: acc, digest: dig, size: size},
Expand Down
3 changes: 3 additions & 0 deletions pkg/blobaccess/file/access.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,9 @@ var (
_ bpi.FileLocation = (*temporaryFileBlob)(nil)
)

// Validate checks if the access is valid, meaning
// it can provide data. Here, this means
// that the file exists.
func (b *temporaryFileBlob) Validate() error {
b.lock.Lock()
defer b.lock.Unlock()
Expand Down

0 comments on commit f5ecdd3

Please sign in to comment.