mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-06-05 07:29:56 +08:00
fix: prevent duplicate transfer uploads
This commit is contained in:
@@ -524,6 +524,9 @@ class U115Pan(StorageBase, metaclass=WeakSingleton):
|
||||
"""
|
||||
|
||||
def encode_callback(cb: str) -> str:
|
||||
"""
|
||||
编码 115 OSS 回调参数。
|
||||
"""
|
||||
return oss2.utils.b64encode_as_string(cb)
|
||||
|
||||
target_name = new_name or local_path.name
|
||||
@@ -631,7 +634,10 @@ class U115Pan(StorageBase, metaclass=WeakSingleton):
|
||||
else None,
|
||||
modify_time=info_resp["utime"],
|
||||
)
|
||||
return self.get_item(target_path)
|
||||
uploaded_item = self.get_item(target_path)
|
||||
return uploaded_item or self.__build_uploaded_fileitem(
|
||||
target_path, local_path, file_size
|
||||
)
|
||||
|
||||
# Step 4: 获取上传凭证
|
||||
token_resp = self._request_api("GET", "/open/upload/get_token", "data")
|
||||
@@ -740,7 +746,30 @@ class U115Pan(StorageBase, metaclass=WeakSingleton):
|
||||
)
|
||||
return None
|
||||
# 返回结果
|
||||
return self.get_item(target_path)
|
||||
uploaded_item = self.get_item(target_path)
|
||||
if uploaded_item:
|
||||
return uploaded_item
|
||||
logger.warn(
|
||||
f"【115】{target_name} 上传已完成但元数据暂不可见,使用目标路径构造整理结果"
|
||||
)
|
||||
return self.__build_uploaded_fileitem(target_path, local_path, file_size)
|
||||
|
||||
def __build_uploaded_fileitem(
|
||||
self, target_path: Path, local_path: Path, file_size: int
|
||||
) -> schemas.FileItem:
|
||||
"""
|
||||
构造已上传文件项,用于兼容 115 上传成功后目录索引延迟刷新。
|
||||
"""
|
||||
return schemas.FileItem(
|
||||
storage=self.schema.value,
|
||||
path=target_path.as_posix(),
|
||||
type="file",
|
||||
name=target_path.name,
|
||||
basename=target_path.stem,
|
||||
extension=target_path.suffix[1:] or None,
|
||||
size=file_size,
|
||||
modify_time=local_path.stat().st_mtime if local_path.exists() else None,
|
||||
)
|
||||
|
||||
def download(self, fileitem: schemas.FileItem, path: Path = None) -> Optional[Path]:
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user