Skip to content

Commit

Permalink
Add protection for 0 byte cache entries
Browse files Browse the repository at this point in the history
  • Loading branch information
oheyadam committed Feb 8, 2024
1 parent 30c60aa commit 163724a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ class S3BuildCacheService(
}

override fun store(key: BuildCacheKey, writer: BuildCacheEntryWriter) {
if (writer.size == 0L) return // do not store empty entries into the cache
logger.info("Storing ${key.blobKey()}")
val cacheKey = key.blobKey()
val output = ByteArrayOutputStream()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ class S3StorageService(
return try {
val inputStream = client.getObject(request)
val blob = inputStream.response() ?: return null
if (blob.contentLength() == 0L) return null // return empty entries as a cache miss
if (blob.contentLength() > sizeThreshold) {
val path = FileHandleInputStream.create()
val outputStream = path.outputStream()
Expand Down

0 comments on commit 163724a

Please sign in to comment.