Skip to content

Commit

Permalink
fix: not existing dir for nested gcs objects (#47)
Browse files Browse the repository at this point in the history
  • Loading branch information
mhordynski authored Sep 26, 2024
1 parent c4647cc commit 9372351
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ async def fetch(self) -> Path:
raise ImportError("You need to install the 'gcloud-aio-storage' package to use Google Cloud Storage")

if (local_dir_env := os.getenv(LOCAL_STORAGE_DIR_ENV)) is None:
local_dir = Path(tempfile.gettempdir())
local_dir = Path(tempfile.gettempdir()) / "ragbits"
else:
local_dir = Path(local_dir_env)

Expand All @@ -117,6 +117,7 @@ async def fetch(self) -> Path:
if not path.is_file():
async with Storage() as client:
content = await client.download(self.bucket, self.object_name)
Path(bucket_local_dir / self.object_name).parent.mkdir(parents=True, exist_ok=True)
with open(path, mode="wb+") as file_object:
file_object.write(content)

Expand Down

0 comments on commit 9372351

Please sign in to comment.