tar.zstd
Browse files- API/app.py +2 -4
API/app.py
CHANGED
|
@@ -234,7 +234,6 @@ async def generate_zstd_archive(posts, session):
|
|
| 234 |
results = await asyncio.gather(*tasks)
|
| 235 |
images = {post_id: image_data for post_id, image_data in results}
|
| 236 |
|
| 237 |
-
# Create a tar in memory
|
| 238 |
tar_buffer = io.BytesIO()
|
| 239 |
with tarfile.open(fileobj=tar_buffer, mode="w") as tar:
|
| 240 |
for post_id, image_data in images.items():
|
|
@@ -244,11 +243,10 @@ async def generate_zstd_archive(posts, session):
|
|
| 244 |
tar.addfile(tarinfo=file_info, fileobj=io.BytesIO(image_data))
|
| 245 |
tar_buffer.seek(0)
|
| 246 |
|
| 247 |
-
|
| 248 |
-
cctx = zstd.ZstdCompressor(level=3)
|
| 249 |
compressed = cctx.compress(tar_buffer.read())
|
| 250 |
|
| 251 |
-
temp_file = tempfile.NamedTemporaryFile(delete=False, suffix=".zstd")
|
| 252 |
temp_file.write(compressed)
|
| 253 |
temp_file.flush()
|
| 254 |
temp_file.seek(0)
|
|
|
|
| 234 |
results = await asyncio.gather(*tasks)
|
| 235 |
images = {post_id: image_data for post_id, image_data in results}
|
| 236 |
|
|
|
|
| 237 |
tar_buffer = io.BytesIO()
|
| 238 |
with tarfile.open(fileobj=tar_buffer, mode="w") as tar:
|
| 239 |
for post_id, image_data in images.items():
|
|
|
|
| 243 |
tar.addfile(tarinfo=file_info, fileobj=io.BytesIO(image_data))
|
| 244 |
tar_buffer.seek(0)
|
| 245 |
|
| 246 |
+
cctx = zstd.ZstdCompressor(level=-1)
|
|
|
|
| 247 |
compressed = cctx.compress(tar_buffer.read())
|
| 248 |
|
| 249 |
+
temp_file = tempfile.NamedTemporaryFile(delete=False, suffix=".tar.zstd")
|
| 250 |
temp_file.write(compressed)
|
| 251 |
temp_file.flush()
|
| 252 |
temp_file.seek(0)
|