fix: 为cache文件batch操作的复制和移动行为创建文件夹

This commit is contained in:
shuohigh@gmail.com 2025-06-24 15:18:23 +08:00
parent ff437e63b3
commit 2a0c3364d0
1 changed files with 3 additions and 0 deletions

View File

@ -13,6 +13,7 @@ from fastapi.responses import JSONResponse, RedirectResponse
from starlette import status
import boto3
from botocore.config import Config
from typing_inspection.typing_objects import target
from ..config import WorkerConfig
from ..middleware.authorization import verify_token
@ -235,6 +236,8 @@ async def s3_copy(body: ClusterCacheBatchRequest) -> ClusterCacheBatchResponse:
results: List[CacheTaskResult] = []
for task in body.tasks:
try:
if task.target:
os.makedirs(os.path.dirname(task.target.local_mount_path), exist_ok=True)
match task.type:
case CacheOperationType.copy:
shutil.copy(task.source.local_mount_path, task.target.local_mount_path)