| 341 | } |
| 342 | |
| 343 | void finalize(Optional<BlobGranuleCipherKeysCtx> cipherKeysCtx, Arena& arena) { |
| 344 | if (cipherKeysCtx.present()) { |
| 345 | // IndexBlock childBlock pointers offsets are relative to IndexBlock endOffset instead of file start offset. |
| 346 | // Compressing indexBlock will need offset recalculation (circular depedency). IndexBlock size is bounded by |
| 347 | // number of chunks and sizeof(KeyPrefix), 'not' compressing IndexBlock shouldn't cause significant file |
| 348 | // size bloat. |
| 349 | |
| 350 | ASSERT(cipherKeysCtx.present()); |
| 351 | encrypt(cipherKeysCtx.get(), arena); |
| 352 | } else { |
| 353 | encryptHeaderRef.reset(); |
| 354 | buffer = StringRef( |
| 355 | arena, ObjectWriter::toValue(block, IncludeVersion(ProtocolVersion::withBlobGranuleFile())).contents()); |
| 356 | } |
| 357 | |
| 358 | if (BG_ENCRYPT_COMPRESS_DEBUG) { |
| 359 | TraceEvent(SevDebug, "IndexBlockSize") |
| 360 | .detail("Sz", buffer.size()) |
| 361 | .detail("Encrypted", cipherKeysCtx.present()); |
| 362 | } |
| 363 | } |
| 364 | |
| 365 | template <class Ar> |
| 366 | void serialize(Ar& ar) { |
no test coverage detected