diff --git a/src/BowongModalFunctions/models/cache_tasks/models.py b/src/BowongModalFunctions/models/cache_tasks/models.py index 886fb9e..432516d 100644 --- a/src/BowongModalFunctions/models/cache_tasks/models.py +++ b/src/BowongModalFunctions/models/cache_tasks/models.py @@ -126,6 +126,8 @@ class MediaSource(BaseModel): return f"{self.protocol.value}/{self.endpoint}/{self.bucket}/{self.path}" case MediaProtocol.http: clean_path = self.path.split('?')[0] if '?' in self.path else self.path + # 移除路径开头的斜杠,避免双斜杠问题 + clean_path = clean_path.lstrip('/') return f"{self.protocol.value}/{self.endpoint}/{clean_path}" case _: return f"{self.protocol.value}/{self.endpoint}/{self.bucket}/{self.path}" @@ -163,7 +165,8 @@ class MediaSource(BaseModel): if self.protocol == MediaProtocol.s3: return f"{self.path}" elif self.protocol == MediaProtocol.http: - return f"{self.protocol.value}/{self.path}" + # 对于HTTP协议,使用cache_filepath确保路径一致性 + return self.cache_filepath return f"{self.protocol.value}/{self.endpoint}/{self.bucket}/{self.path}" @computed_field(description="CDN挂载地址") diff --git a/src/cluster/video_apps/cache_submit.py b/src/cluster/video_apps/cache_submit.py index fa1594c..5843cb9 100644 --- a/src/cluster/video_apps/cache_submit.py +++ b/src/cluster/video_apps/cache_submit.py @@ -190,7 +190,7 @@ with downloader_image.imports(): raise e case MediaProtocol.http: try: - cache_filepath = f"{config.S3_mount_dir}/{media.protocol.value}/{media.cache_filepath}" + cache_filepath = f"{config.S3_mount_dir}/{media.cache_filepath}" os.makedirs(os.path.dirname(cache_filepath), exist_ok=True) download_large_file(url=media.__str__(), output_path=cache_filepath) except Exception as e: