Procházet zdrojové kódy

Merge pull request #11236 from overleaf/jpa-pdf-caching-fix-size-estimation

[web] pdf-caching: fix estimation of multipart response size

GitOrigin-RevId: 5929cc1e413befb3f931889b38a4b21a7ed4cea8
Jakob Ackermann před 3 roky
rodič
revize
6154db8f92

+ 3 - 2
services/web/frontend/js/features/pdf-preview/util/pdf-caching.js

@@ -10,7 +10,7 @@ const HEADER_OVERHEAD_PER_MULTI_PART_CHUNK = composeMultipartHeader({
   start: 9 * 1024 * 1024 * 1024,
   end: 9 * 1024 * 1024 * 1024,
   size: 9 * 1024 * 1024 * 1024,
-})
+}).length
 const MULTI_PART_THRESHOLD = 4
 const INCREMENTAL_CACHE_SIZE = 1000
 // Download large chunks once the shard bandwidth exceeds 50% of their size.
@@ -88,7 +88,8 @@ function estimateSizeOfMultipartResponse(chunks) {
       (totalBytes, chunk) =>
         totalBytes +
         HEADER_OVERHEAD_PER_MULTI_PART_CHUNK +
-        (chunk.end - chunk.start)
+        (chunk.end - chunk.start),
+      0
     ) + ('\r\n' + SAMPLE_NGINX_BOUNDARY + '--').length
   )
 }