Skip to content

Commit c6be312

Browse files
committed
fix: make path to objects in S3 not platform specific
1 parent 3001ad1 commit c6be312

2 files changed

Lines changed: 5 additions & 6 deletions

File tree

src/taskiq_sqs/bucket.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ class S3Bucket:
77
Represents an S3 bucket configuration.
88
99
Attributes:
10-
name: The name of the bucjet.
10+
name: The name of the bucket.
1111
declare: Whether to create the bucket on startup if it not exists yet.
1212
"""
1313
name: str

src/taskiq_sqs/result_backend.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from pathlib import Path
21
from typing import TYPE_CHECKING, Any, TypeVar
32

43
from aiobotocore.session import get_session
@@ -35,7 +34,7 @@ def __init__(
3534
"""
3635
Constructs a new S3 result backend.
3736
38-
:param bucket_name: name of the bucket on S3.
37+
:param bucket: S3 bucket configuration.
3938
:param base_path: base path for results.
4039
:param endpoint_url: endpoint URL for S3.
4140
:param aws_region_name: AWS region, default is 'us-east-1'.
@@ -112,7 +111,7 @@ async def set_result(
112111
:param result: result of execution.
113112
"""
114113
if self._base_path:
115-
task_id = str(Path(self._base_path) / task_id)
114+
task_id = f"{self._base_path.rstrip('/')}/{task_id}"
116115

117116
await self._s3_client.put_object(
118117
Bucket=self._bucket.name,
@@ -137,7 +136,7 @@ async def get_result(
137136
"""
138137
result = None
139138
if self._base_path:
140-
task_id = str(Path(self._base_path) / task_id)
139+
task_id = f"{self._base_path.rstrip('/')}/{task_id}"
141140
try:
142141
if response := await self._s3_client.get_object(
143142
Bucket=self._bucket.name,
@@ -171,7 +170,7 @@ async def is_result_ready(self, task_id: str) -> bool:
171170
:return: True if result is ready.
172171
"""
173172
if self._base_path:
174-
task_id = str(Path(self._base_path) / task_id)
173+
task_id = f"{self._base_path.rstrip('/')}/{task_id}"
175174
try:
176175
if await self._s3_client.head_object(Bucket=self._bucket.name, Key=task_id):
177176
return True

0 commit comments

Comments
 (0)