mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-08 17:08:35 +08:00
fix delay get_item
This commit is contained in:
@@ -435,6 +435,17 @@ class AliPan(StorageBase, metaclass=Singleton):
|
|||||||
break
|
break
|
||||||
return items
|
return items
|
||||||
|
|
||||||
|
def _delay_get_item(self, path: Path) -> Optional[schemas.FileItem]:
|
||||||
|
"""
|
||||||
|
自动延迟重试 get_item 模块
|
||||||
|
"""
|
||||||
|
for _ in range(2):
|
||||||
|
time.sleep(2)
|
||||||
|
fileitem = self.get_item(path)
|
||||||
|
if fileitem:
|
||||||
|
return fileitem
|
||||||
|
return None
|
||||||
|
|
||||||
def create_folder(self, parent_item: schemas.FileItem, name: str) -> Optional[schemas.FileItem]:
|
def create_folder(self, parent_item: schemas.FileItem, name: str) -> Optional[schemas.FileItem]:
|
||||||
"""
|
"""
|
||||||
创建目录
|
创建目录
|
||||||
@@ -457,7 +468,7 @@ class AliPan(StorageBase, metaclass=Singleton):
|
|||||||
# 缓存新目录
|
# 缓存新目录
|
||||||
new_path = Path(parent_item.path) / name
|
new_path = Path(parent_item.path) / name
|
||||||
self._id_cache[str(new_path)] = (resp.get("drive_id"), resp.get("file_id"))
|
self._id_cache[str(new_path)] = (resp.get("drive_id"), resp.get("file_id"))
|
||||||
return self.get_item(new_path)
|
return self._delay_get_item(new_path)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _calculate_pre_hash(file_path: Path):
|
def _calculate_pre_hash(file_path: Path):
|
||||||
@@ -676,7 +687,7 @@ class AliPan(StorageBase, metaclass=Singleton):
|
|||||||
chunk_size=chunk_size)
|
chunk_size=chunk_size)
|
||||||
if create_res.get('rapid_upload', False):
|
if create_res.get('rapid_upload', False):
|
||||||
logger.info(f"【阿里云盘】{target_name} 秒传完成!")
|
logger.info(f"【阿里云盘】{target_name} 秒传完成!")
|
||||||
return self.get_item(target_path)
|
return self._delay_get_item(target_path)
|
||||||
|
|
||||||
if create_res.get("exist", False):
|
if create_res.get("exist", False):
|
||||||
logger.info(f"【阿里云盘】{target_name} 已存在")
|
logger.info(f"【阿里云盘】{target_name} 已存在")
|
||||||
@@ -919,7 +930,7 @@ class AliPan(StorageBase, metaclass=Singleton):
|
|||||||
return False
|
return False
|
||||||
# 重命名
|
# 重命名
|
||||||
new_path = Path(path) / fileitem.name
|
new_path = Path(path) / fileitem.name
|
||||||
new_file = self.get_item(new_path)
|
new_file = self._delay_get_item(new_path)
|
||||||
self.rename(new_file, new_name)
|
self.rename(new_file, new_name)
|
||||||
# 更新缓存
|
# 更新缓存
|
||||||
del self._id_cache[fileitem.path]
|
del self._id_cache[fileitem.path]
|
||||||
|
|||||||
@@ -306,7 +306,7 @@ class U115Pan(StorageBase, metaclass=Singleton):
|
|||||||
sha1.update(chunk)
|
sha1.update(chunk)
|
||||||
return sha1.hexdigest()
|
return sha1.hexdigest()
|
||||||
|
|
||||||
def _delay_get_item(self, path: Path) -> List[schemas.FileItem]:
|
def _delay_get_item(self, path: Path) -> Optional[schemas.FileItem]:
|
||||||
"""
|
"""
|
||||||
自动延迟重试 get_item 模块
|
自动延迟重试 get_item 模块
|
||||||
"""
|
"""
|
||||||
|
|||||||
Reference in New Issue
Block a user