mirror of
https://github.com/dograh-hq/dograh.git
synced 2026-07-13 11:22:14 +02:00
feat: enable duplicate workflow feature
This commit is contained in:
parent
c61a3843a5
commit
93c45580e7
8 changed files with 396 additions and 2 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue