mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-05 07:27:15 +08:00
Merge pull request #4344 from DDS-Derek/dev
This commit is contained in:
@@ -8,13 +8,15 @@ from app.utils.system import SystemUtils
|
|||||||
|
|
||||||
|
|
||||||
class SystemHelper:
|
class SystemHelper:
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def can_restart() -> bool:
|
def can_restart() -> bool:
|
||||||
"""
|
"""
|
||||||
判断是否可以内部重启
|
判断是否可以内部重启
|
||||||
"""
|
"""
|
||||||
return Path("/var/run/docker.sock").exists()
|
return (
|
||||||
|
Path("/var/run/docker.sock").exists()
|
||||||
|
or settings.DOCKER_CLIENT_API != "tcp://127.0.0.1:38379"
|
||||||
|
)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def restart() -> Tuple[bool, str]:
|
def restart() -> Tuple[bool, str]:
|
||||||
@@ -28,7 +30,7 @@ class SystemHelper:
|
|||||||
client = docker.DockerClient(base_url=settings.DOCKER_CLIENT_API)
|
client = docker.DockerClient(base_url=settings.DOCKER_CLIENT_API)
|
||||||
# 获取当前容器的 ID
|
# 获取当前容器的 ID
|
||||||
container_id = None
|
container_id = None
|
||||||
with open('/proc/self/mountinfo', 'r') as f:
|
with open("/proc/self/mountinfo", "r") as f:
|
||||||
data = f.read()
|
data = f.read()
|
||||||
index_resolv_conf = data.find("resolv.conf")
|
index_resolv_conf = data.find("resolv.conf")
|
||||||
if index_resolv_conf != -1:
|
if index_resolv_conf != -1:
|
||||||
@@ -39,7 +41,9 @@ class SystemHelper:
|
|||||||
index_resolv_conf = data.find("/sys/fs/cgroup/devices")
|
index_resolv_conf = data.find("/sys/fs/cgroup/devices")
|
||||||
if index_resolv_conf != -1:
|
if index_resolv_conf != -1:
|
||||||
index_second_slash = data.rfind(" ", 0, index_resolv_conf)
|
index_second_slash = data.rfind(" ", 0, index_resolv_conf)
|
||||||
index_first_slash = data.rfind("/", 0, index_second_slash) + 1
|
index_first_slash = (
|
||||||
|
data.rfind("/", 0, index_second_slash) + 1
|
||||||
|
)
|
||||||
container_id = data[index_first_slash:index_second_slash]
|
container_id = data[index_first_slash:index_second_slash]
|
||||||
if not container_id:
|
if not container_id:
|
||||||
return False, "获取容器ID失败!"
|
return False, "获取容器ID失败!"
|
||||||
|
|||||||
@@ -524,6 +524,31 @@ class U115Pan(StorageBase, metaclass=Singleton):
|
|||||||
# Step 3: 秒传
|
# Step 3: 秒传
|
||||||
if init_result.get("status") == 2:
|
if init_result.get("status") == 2:
|
||||||
logger.info(f"【115】{target_name} 秒传成功")
|
logger.info(f"【115】{target_name} 秒传成功")
|
||||||
|
file_id = init_result.get("file_id", None)
|
||||||
|
if file_id:
|
||||||
|
logger.debug(f"【115】{target_name} 使用秒传返回ID获取文件信息")
|
||||||
|
time.sleep(2)
|
||||||
|
info_resp = self._request_api(
|
||||||
|
"GET",
|
||||||
|
"/open/folder/get_info",
|
||||||
|
"data",
|
||||||
|
params={
|
||||||
|
"file_id": int(file_id)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
if info_resp:
|
||||||
|
return schemas.FileItem(
|
||||||
|
storage=self.schema.value,
|
||||||
|
fileid=str(info_resp["file_id"]),
|
||||||
|
path=str(target_path) + ("/" if info_resp["file_category"] == "0" else ""),
|
||||||
|
type="file" if info_resp["file_category"] == "1" else "dir",
|
||||||
|
name=info_resp["file_name"],
|
||||||
|
basename=Path(info_resp["file_name"]).stem,
|
||||||
|
extension=Path(info_resp["file_name"]).suffix[1:] if info_resp["file_category"] == "1" else None,
|
||||||
|
pickcode=info_resp["pick_code"],
|
||||||
|
size=StringUtils.num_filesize(info_resp['size']) if info_resp["file_category"] == "1" else None,
|
||||||
|
modify_time=info_resp["utime"]
|
||||||
|
)
|
||||||
return self._delay_get_item(target_path)
|
return self._delay_get_item(target_path)
|
||||||
|
|
||||||
# Step 4: 获取上传凭证
|
# Step 4: 获取上传凭证
|
||||||
|
|||||||
Reference in New Issue
Block a user