Skip to content

Commit c430af3

Browse files
committed
feat: 适配alist webdav
1 parent 6fcf26f commit c430af3

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

core/storage.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# @Author : Lan
33
# @File : storage.py
44
# @Software: PyCharm
5+
import base64
56
import hashlib
67
from core.logger import logger
78
import shutil
@@ -656,7 +657,6 @@ async def delete_file(self, file_code: FileCodes):
656657
"""删除WebDAV文件及空目录"""
657658
file_path = await file_code.get_file_path()
658659
url = self._build_url(file_path)
659-
660660
try:
661661
async with aiohttp.ClientSession(auth=self.auth) as session:
662662
# 删除文件
@@ -683,7 +683,9 @@ async def get_file_response(self, file_code: FileCodes):
683683
try:
684684
filename = file_code.prefix + file_code.suffix
685685
url = self._build_url(await file_code.get_file_path())
686-
async with aiohttp.ClientSession(auth=self.auth) as session:
686+
async with aiohttp.ClientSession(headers={
687+
"Authorization": f"Basic {base64.b64encode(f'{settings.webdav_username}:{settings.webdav_password}'.encode()).decode()}"
688+
}) as session:
687689
async with session.get(url) as resp:
688690
if resp.status != 200:
689691
raise HTTPException(

0 commit comments

Comments
 (0)