mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-06 16:07:01 +08:00
fix alipan
This commit is contained in:
@@ -11,6 +11,7 @@ import oss2
|
|||||||
import requests
|
import requests
|
||||||
from oss2 import SizedFileAdapter, determine_part_size
|
from oss2 import SizedFileAdapter, determine_part_size
|
||||||
from oss2.models import PartInfo
|
from oss2.models import PartInfo
|
||||||
|
from requests.packages import target
|
||||||
|
|
||||||
from app import schemas
|
from app import schemas
|
||||||
from app.core.config import settings
|
from app.core.config import settings
|
||||||
@@ -801,52 +802,56 @@ class AliPan(StorageBase, metaclass=Singleton):
|
|||||||
|
|
||||||
resp = self._request_api(
|
resp = self._request_api(
|
||||||
"POST",
|
"POST",
|
||||||
"/open/ufile/copy",
|
"/adrive/v1.0/openFile/copy",
|
||||||
json={
|
json={
|
||||||
|
"drive_id": fileitem.drive_id,
|
||||||
"file_id": src_fid,
|
"file_id": src_fid,
|
||||||
"pid": dest_cid
|
"to_drive_id": fileitem.drive_id,
|
||||||
|
"to_parent_file_id": dest_cid
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
if not resp:
|
if not resp:
|
||||||
return False
|
return False
|
||||||
if resp["state"]:
|
if resp.get("code"):
|
||||||
new_path = Path(path) / fileitem.name
|
logger.warn(f"【阿里云盘】复制文件失败: {resp.get('message')}")
|
||||||
new_file = self.get_item(new_path)
|
return False
|
||||||
self.rename(new_file, new_name)
|
# 重命名
|
||||||
# 更新缓存
|
new_path = Path(path) / fileitem.name
|
||||||
del self._id_cache[fileitem.path]
|
new_file = self.get_item(new_path)
|
||||||
rename_new_path = Path(path) / new_name
|
self.rename(new_file, new_name)
|
||||||
self._id_cache[str(rename_new_path)] = int(new_file.fileid)
|
# 更新缓存
|
||||||
return True
|
del self._id_cache[fileitem.path]
|
||||||
return False
|
rename_new_path = Path(path) / new_name
|
||||||
|
self._id_cache[str(rename_new_path)] = int(new_file.fileid)
|
||||||
|
return True
|
||||||
|
|
||||||
def move(self, fileitem: schemas.FileItem, path: Path, new_name: str) -> bool:
|
def move(self, fileitem: schemas.FileItem, path: Path, new_name: str) -> bool:
|
||||||
"""
|
"""
|
||||||
原子性移动操作实现
|
原子性移动操作实现
|
||||||
"""
|
"""
|
||||||
src_fid = self._path_to_id(fileitem.path)
|
src_fid = self._path_to_id(fileitem.path)
|
||||||
dest_cid = self._path_to_id(str(path))
|
target_id = self._path_to_id(str(path))
|
||||||
|
|
||||||
resp = self._request_api(
|
resp = self._request_api(
|
||||||
"POST",
|
"POST",
|
||||||
"/open/ufile/move",
|
"/adrive/v1.0/openFile/move",
|
||||||
json={
|
json={
|
||||||
"file_ids": src_fid,
|
"drive_id": fileitem.drive_id,
|
||||||
"to_cid": dest_cid
|
"file_id": src_fid,
|
||||||
|
"to_parent_file_id": target_id,
|
||||||
|
"new_name": new_name
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
if not resp:
|
if not resp:
|
||||||
return False
|
return False
|
||||||
if resp["state"]:
|
if resp.get("code"):
|
||||||
new_path = Path(path) / fileitem.name
|
logger.warn(f"【阿里云盘】移动文件失败: {resp.get('message')}")
|
||||||
new_file = self.get_item(new_path)
|
return False
|
||||||
self.rename(new_file, new_name)
|
# 更新缓存
|
||||||
# 更新缓存
|
del self._id_cache[fileitem.path]
|
||||||
del self._id_cache[fileitem.path]
|
rename_new_path = Path(path) / new_name
|
||||||
rename_new_path = Path(path) / new_name
|
self._id_cache[str(rename_new_path)] = src_fid
|
||||||
self._id_cache[str(rename_new_path)] = src_fid
|
return True
|
||||||
return True
|
|
||||||
return False
|
|
||||||
|
|
||||||
def link(self, fileitem: schemas.FileItem, target_file: Path) -> bool:
|
def link(self, fileitem: schemas.FileItem, target_file: Path) -> bool:
|
||||||
pass
|
pass
|
||||||
@@ -860,16 +865,17 @@ class AliPan(StorageBase, metaclass=Singleton):
|
|||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
resp = self._request_api(
|
resp = self._request_api(
|
||||||
"GET",
|
"POST",
|
||||||
"/open/user/info",
|
"/adrive/v1.0/user/getSpaceInfo"
|
||||||
"data"
|
|
||||||
)
|
)
|
||||||
if not resp:
|
if not resp:
|
||||||
return None
|
return None
|
||||||
space = resp["rt_space_info"]
|
space = resp.get("personal_space_info") or {}
|
||||||
|
total_size = space.get("total_size") or 0
|
||||||
|
used_size = space.get("used_size") or 0
|
||||||
return schemas.StorageUsage(
|
return schemas.StorageUsage(
|
||||||
total=space["all_total"]["size"],
|
total=total_size,
|
||||||
available=space["all_remain"]["size"]
|
available=total_size - used_size
|
||||||
)
|
)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
return None
|
return None
|
||||||
|
|||||||
Reference in New Issue
Block a user