mirror of
https://github.com/Cp0204/quark-auto-save.git
synced 2026-01-18 02:40:44 +08:00
feat(alist): 新增 Alist 挂载的 Quark 根目录配置, 适配 Alist 挂载 Quark 子目录的情况, 默认为 /
This commit is contained in:
parent
179856adca
commit
640abe5d64
@ -5,7 +5,7 @@ import requests
|
|||||||
|
|
||||||
class Alist:
|
class Alist:
|
||||||
|
|
||||||
default_config = {"url": "", "token": "", "path_prefix": "/quark"}
|
default_config = {"url": "", "token": "", "path_prefix": "/quark", "quark_root_dir": "/"}
|
||||||
is_active = False
|
is_active = False
|
||||||
|
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
@ -20,7 +20,7 @@ class Alist:
|
|||||||
self.is_active = True
|
self.is_active = True
|
||||||
|
|
||||||
def run(self, task):
|
def run(self, task):
|
||||||
if task.get("savepath"):
|
if task.get("savepath") and task.get("savepath").startswith(self.quark_root_dir):
|
||||||
path = self._normalize_path(task["savepath"])
|
path = self._normalize_path(task["savepath"])
|
||||||
self.refresh(path)
|
self.refresh(path)
|
||||||
|
|
||||||
@ -81,5 +81,5 @@ class Alist:
|
|||||||
def _normalize_path(self, path):
|
def _normalize_path(self, path):
|
||||||
"""标准化路径格式"""
|
"""标准化路径格式"""
|
||||||
if not path.startswith(self.path_prefix):
|
if not path.startswith(self.path_prefix):
|
||||||
path = f"/{self.path_prefix}/{path}"
|
path = f"/{self.path_prefix}/{path.lstrip(self.quark_root_dir)}"
|
||||||
return re.sub(r"/{2,}", "/", path)
|
return re.sub(r"/{2,}", "/", path)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user