Skip to content

Commit

Permalink
💫 Create cache directory right before write content
Browse files Browse the repository at this point in the history
  • Loading branch information
waketzheng committed Oct 29, 2024
1 parent eeeb0c2 commit bb37359
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions fastapi_cdn_host/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,11 +302,11 @@ def wrapper(*args, **kw):
return AssetUrl(
css=css, js=js, redoc=redoc, favicon=self.favicon_url
)
elif not (parent := file.parent).exists():
parent.mkdir(parents=True)
logger.info(f"{parent} created!")
urls = func(*args, **kw)
content = "\n".join([urls.css, urls.js, urls.redoc]).encode()
if not (parent := file.parent).exists():
parent.mkdir(parents=True)
logger.info(f"{parent} created!")
size = file.write_bytes(content)
logger.info(f"Save urls to {file} with {size=}.")
return urls
Expand Down

0 comments on commit bb37359

Please sign in to comment.