feat: 适配alist webdav

This commit is contained in:
Lan
2025-04-19 17:58:58 +08:00
parent 0456996f7f
commit ee64e67601
+4 -2
View File
@@ -2,6 +2,7 @@
# @Author : Lan # @Author : Lan
# @File : storage.py # @File : storage.py
# @Software: PyCharm # @Software: PyCharm
import base64
import hashlib import hashlib
from core.logger import logger from core.logger import logger
import shutil import shutil
@@ -656,7 +657,6 @@ class WebDAVFileStorage(FileStorageInterface):
"""删除WebDAV文件及空目录""" """删除WebDAV文件及空目录"""
file_path = await file_code.get_file_path() file_path = await file_code.get_file_path()
url = self._build_url(file_path) url = self._build_url(file_path)
try: try:
async with aiohttp.ClientSession(auth=self.auth) as session: async with aiohttp.ClientSession(auth=self.auth) as session:
# 删除文件 # 删除文件
@@ -683,7 +683,9 @@ class WebDAVFileStorage(FileStorageInterface):
try: try:
filename = file_code.prefix + file_code.suffix filename = file_code.prefix + file_code.suffix
url = self._build_url(await file_code.get_file_path()) url = self._build_url(await file_code.get_file_path())
async with aiohttp.ClientSession(auth=self.auth) as session: async with aiohttp.ClientSession(headers={
"Authorization": f"Basic {base64.b64encode(f'{settings.webdav_username}:{settings.webdav_password}'.encode()).decode()}"
}) as session:
async with session.get(url) as resp: async with session.get(url) as resp:
if resp.status != 200: if resp.status != 200:
raise HTTPException( raise HTTPException(