Skip to content

Commit 93990c2

Browse files
committed
⚡️ Speed up archive creation
1 parent 38c8049 commit 93990c2

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ dependencies = [
3838
"rich-toolkit >= 0.14.5",
3939
"pydantic[email] >= 1.6.1",
4040
"sentry-sdk >= 2.20.0",
41+
"fastar >= 0.5.0",
4142
]
4243

4344
[project.optional-dependencies]

src/fastapi_cloud_cli/commands/deploy.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
import json
33
import logging
44
import subprocess
5-
import tarfile
65
import tempfile
76
import time
87
from enum import Enum
98
from itertools import cycle
109
from pathlib import Path
1110
from typing import Any, Dict, Generator, List, Optional, Union
1211

12+
import fastar
1313
import rignore
1414
import typer
1515
from httpx import Client
@@ -56,13 +56,14 @@ def archive(path: Path, tar_path: Path) -> Path:
5656
logger.debug("Archive will be created at: %s", tar_path)
5757

5858
file_count = 0
59-
with tarfile.open(tar_path, "w") as tar:
59+
with fastar.open(tar_path, "w") as tar:
6060
for filename in files:
6161
if filename.is_dir():
6262
continue
6363

64-
logger.debug("Adding %s to archive", filename.relative_to(path))
65-
tar.add(filename, arcname=filename.relative_to(path))
64+
arcname = filename.relative_to(path)
65+
logger.debug("Adding %s to archive", arcname)
66+
tar.append(filename, arcname=arcname)
6667
file_count += 1
6768

6869
logger.debug("Archive created successfully with %s files", file_count)

0 commit comments

Comments
 (0)