Skip to content

Commit

Permalink
Generate: Only save .tgz files when setting a toggle
Browse files Browse the repository at this point in the history
  • Loading branch information
Croydon committed May 9, 2024
1 parent 46008ea commit 1abe4cc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/generate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
- uses: actions/checkout@v4
with:
repository: "bincrafters/remote"
ref: "testing/v-999"
ref: "testing/v-998"
path: "remote"
token: ${{ secrets.BOT_GITHUB_TOKEN }}
- uses: actions/setup-python@v5
Expand Down
7 changes: 5 additions & 2 deletions generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
logger.addHandler(logging.StreamHandler())

cached_headers = {}
# Toggle, if True then it saves .tgz files
CREATE_FULL_LOCAL_BACKUP = False

async def make_request(getting_url: str, user_agent: str):
async with httpx.AsyncClient(follow_redirects=True) as client:
Expand Down Expand Up @@ -102,8 +104,9 @@ async def get_external_site(request: Request, url_path: str):

if not url_path in ["v1/ping",]:
if filename.endswith(".tgz"):
with open(os.path.join(cache_path), "wb") as f:
f.write(r.content)
if CREATE_FULL_LOCAL_BACKUP:
with open(os.path.join(cache_path), "wb") as f:
f.write(r.content)
tar_file = tarfile.open(fileobj=io.BytesIO(r.content), mode='r:gz')
tar_file.extractall(os.path.join(cache_dir, new_tgz_file_dir))
json_data = {"files": [f"{new_tgz_file_dir}/{f.name}" for f in tar_file.getmembers()]}
Expand Down

0 comments on commit 1abe4cc

Please sign in to comment.