Generate SSD ZIP entry streaming from typed Jerboa

ober

299ec41f79072922a34bc3f6eaa4cc375c84311e

diff --git a/templates/ssd-review.ss b/templates/ssd-review.ss
index 2de610b..343394e 100644
--- a/templates/ssd-review.ss
+++ b/templates/ssd-review.ss
@@ -15568,6 +15568,7 @@
                       (java time Instant)
                       (java time OffsetDateTime)
                       (java time format DateTimeFormatter)
+                      (java util zip ZipInputStream)
                       (javax net ssl HttpsURLConnection)
                       (org json JSONArray)
                       (org json JSONObject))
@@ -15594,6 +15595,7 @@
                 truthStoreSaveTruthSnapshotLocal
                 truthStoreMergeJsonLinesLocal
                 truthStorePushRemoteDumpLocal
+                truthStoreStreamZipEntryLocal
                 truthStoreInstallStagedZipEntryLocal
                 truthStorePullRemoteDumpLocal)
         (type AssetManager)
@@ -15606,6 +15608,7 @@
         (type InputStream)
         (type Int32)
         (type LinkOption)
+        (type LimitedInputStream)
         (type HttpsURLConnection)
         (type MessageDigest)
         (type Number)
@@ -15620,6 +15623,7 @@
         (type URL)
         (type JSONArray)
         (type JSONObject)
+        (type ZipInputStream)
         (extern (truthStoreRoot
                   (store : TruthStore)) : File
           (kotlin-member-get root))
@@ -15704,6 +15708,9 @@
         (extern (truthStoreStagedZipEntryFile
                   (entry : StagedZipEntry)) : File
           (kotlin-member-get _file))
+        (extern (truthStoreLimitedInputStreamCount
+                  (input : LimitedInputStream)) : Int
+          (kotlin-member-get count))
         (extern (truthStoreJsonToPrettyString
                   (json : JSONObject)
                   (indent : Int32)) : String
@@ -15868,6 +15875,10 @@
           (kotlin-value MAX_REMOTE_ZIP_BYTES))
         (extern (truthStoreMaxZipTotalBytes) : Int
           (kotlin-value MAX_ZIP_TOTAL_BYTES))
+        (extern (truthStoreRatioFloorBytes) : Int
+          (kotlin-value RATIO_FLOOR_BYTES))
+        (extern (truthStoreMaxCompressionRatio) : Int
+          (kotlin-value MAX_COMPRESSION_RATIO))
         (extern (truthStoreMaxStorageBytes) : Int
           (kotlin-value MAX_STORAGE_BYTES))
         (extern (truthStoreMaxStorageFiles) : Int32
@@ -16607,6 +16618,24 @@
                                 connection))))))
                     (truthStoreConnectionDisconnect connection))))
               (truthStoreDeleteFileUnit archive))))
+        (def (truthStoreStreamZipEntryLocal
+               (zip : ZipInputStream)
+               (destination : File)
+               (compressed : LimitedInputStream)
+               (budget : ImportBudget)) : Unit
+          (let ((output
+                  (truthStoreFileOutputStream destination)))
+            (try-finally
+              (streamZipEntryToOutput
+                zip
+                output
+                budget
+                (truthStoreMaxZipEntryBytes)
+                (truthStoreMaxZipTotalBytes)
+                (truthStoreRatioFloorBytes)
+                (truthStoreMaxCompressionRatio)
+                (lambda () (truthStoreLimitedInputStreamCount compressed)))
+              (truthStoreOutputStreamClose output))))
         (def (truthStoreReadStagedZipEntryBytesLocal
                (entry : StagedZipEntry)) : Bytes
           (let ((input
@@ -17057,19 +17086,8 @@
        "        destination: File,"
        "        compressed: LimitedInputStream,"
        "        budget: ImportBudget"
-       "    ) {"
-       "        destination.outputStream().use { output ->"
-       "            streamZipEntryToOutput("
-       "                zip,"
-       "                output,"
-       "                budget,"
-       "                MAX_ZIP_ENTRY_BYTES,"
-       "                MAX_ZIP_TOTAL_BYTES,"
-       "                RATIO_FLOOR_BYTES,"
-       "                MAX_COMPRESSION_RATIO"
-       "            ) { compressed.count }"
-       "        }"
-       "    }"
+       "    ) ="
+       "        truthStoreStreamZipEntryLocal(zip, destination, compressed, budget)"
        ""
        "    private fun installStagedZipEntry(entry: StagedZipEntry): Boolean ="
        "        truthStoreInstallStagedZipEntryLocal(this, entry)"