feat: enable duplicate workflow feature

This commit is contained in:
Abhishek Kumar 2026-03-21 12:21:40 +05:30
parent c61a3843a5
commit 93c45580e7
8 changed files with 396 additions and 2 deletions

View file

@ -98,3 +98,16 @@ class BaseFileSystem(ABC):
bool: True if file was downloaded successfully, False otherwise
"""
pass
@abstractmethod
async def acopy_file(self, source_path: str, destination_path: str) -> bool:
"""Copy a file within storage (server-side copy).
Args:
source_path: Path to the source file
destination_path: Path for the copied file
Returns:
bool: True if file was copied successfully, False otherwise
"""
pass

View file

@ -182,3 +182,20 @@ class MinioFileSystem(BaseFileSystem):
return True
except S3Error:
return False
async def acopy_file(self, source_path: str, destination_path: str) -> bool:
"""Copy a file within MinIO (server-side copy)."""
try:
from minio.commonconfig import CopySource
def _copy():
self.client.copy_object(
self.bucket_name,
destination_path,
CopySource(self.bucket_name, source_path),
)
await asyncio.to_thread(_copy)
return True
except S3Error:
return False

View file

@ -137,3 +137,18 @@ class S3FileSystem(BaseFileSystem):
return True
except ClientError:
return False
async def acopy_file(self, source_path: str, destination_path: str) -> bool:
"""Copy a file within S3 (server-side copy)."""
try:
async with self.session.client(
"s3", region_name=self.region_name
) as s3_client:
await s3_client.copy_object(
Bucket=self.bucket_name,
Key=destination_path,
CopySource={"Bucket": self.bucket_name, "Key": source_path},
)
return True
except ClientError:
return False