- Updated import statements in the following files to import ResponseBase directly from models instead of models.response: - routers/api/v1/share/__init__.py - routers/api/v1/site/__init__.py - routers/api/v1/slave/__init__.py - routers/api/v1/tag/__init__.py - routers/api/v1/user/__init__.py - routers/api/v1/vas/__init__.py - routers/api/v1/webdav/__init__.py Enhance user registration and related endpoints in user router - Changed return type annotations from models.response.ResponseBase to models.ResponseBase in multiple functions. - Updated return statements to reflect the new import structure. - Improved documentation for clarity. Add PhysicalFile model and storage service implementation - Introduced PhysicalFile model to represent actual files on disk with reference counting logic. - Created storage service module with local storage implementation, including file operations and error handling. - Defined exceptions for storage operations to improve error handling. - Implemented naming rule parser for generating file and directory names based on templates. Update dependency management in uv.lock - Added aiofiles version 25.1.0 to the project dependencies.
114 lines
2.9 KiB
Python
114 lines
2.9 KiB
Python
from fastapi import APIRouter, Depends
|
|
from middleware.auth import SignRequired
|
|
from models import ResponseBase
|
|
|
|
download_router = APIRouter(
|
|
prefix="/download",
|
|
tags=["download"]
|
|
)
|
|
|
|
aria2_router = APIRouter(
|
|
prefix="/aria2",
|
|
tags=["aria2"]
|
|
)
|
|
|
|
download_router.include_router(aria2_router)
|
|
|
|
@aria2_router.post(
|
|
path='/url',
|
|
summary='创建URL下载任务',
|
|
description='Create a URL download task endpoint.',
|
|
dependencies=[Depends(SignRequired)]
|
|
)
|
|
def router_aria2_url() -> ResponseBase:
|
|
"""
|
|
Create a URL download task endpoint.
|
|
|
|
Returns:
|
|
ResponseBase: A model containing the response data for the URL download task.
|
|
"""
|
|
pass
|
|
|
|
@aria2_router.post(
|
|
path='/torrent/{id}',
|
|
summary='创建种子下载任务',
|
|
description='Create a torrent download task endpoint.',
|
|
dependencies=[Depends(SignRequired)]
|
|
)
|
|
def router_aria2_torrent(id: str) -> ResponseBase:
|
|
"""
|
|
Create a torrent download task endpoint.
|
|
|
|
Args:
|
|
id (str): The ID of the torrent to download.
|
|
|
|
Returns:
|
|
ResponseBase: A model containing the response data for the torrent download task.
|
|
"""
|
|
pass
|
|
|
|
@aria2_router.put(
|
|
path='/select/{gid}',
|
|
summary='重新选择要下载的文件',
|
|
description='Re-select files to download endpoint.',
|
|
dependencies=[Depends(SignRequired)]
|
|
)
|
|
def router_aria2_select(gid: str) -> ResponseBase:
|
|
"""
|
|
Re-select files to download endpoint.
|
|
|
|
Args:
|
|
gid (str): The GID of the download task.
|
|
|
|
Returns:
|
|
ResponseBase: A model containing the response data for the re-selection of files.
|
|
"""
|
|
pass
|
|
|
|
@aria2_router.delete(
|
|
path='/task/{gid}',
|
|
summary='取消或删除下载任务',
|
|
description='Delete a download task endpoint.',
|
|
dependencies=[Depends(SignRequired)]
|
|
)
|
|
def router_aria2_delete(gid: str) -> ResponseBase:
|
|
"""
|
|
Delete a download task endpoint.
|
|
|
|
Args:
|
|
gid (str): The GID of the download task to delete.
|
|
|
|
Returns:
|
|
ResponseBase: A model containing the response data for the deletion of the download task.
|
|
"""
|
|
pass
|
|
|
|
@aria2_router.get(
|
|
'/downloading',
|
|
summary='获取正在下载中的任务',
|
|
description='Get currently downloading tasks endpoint.',
|
|
dependencies=[Depends(SignRequired)]
|
|
)
|
|
def router_aria2_downloading() -> ResponseBase:
|
|
"""
|
|
Get currently downloading tasks endpoint.
|
|
|
|
Returns:
|
|
ResponseBase: A model containing the response data for currently downloading tasks.
|
|
"""
|
|
pass
|
|
|
|
@aria2_router.get(
|
|
path='/finished',
|
|
summary='获取已完成的任务',
|
|
description='Get finished tasks endpoint.',
|
|
dependencies=[Depends(SignRequired)]
|
|
)
|
|
def router_aria2_finished() -> ResponseBase:
|
|
"""
|
|
Get finished tasks endpoint.
|
|
|
|
Returns:
|
|
ResponseBase: A model containing the response data for finished tasks.
|
|
"""
|
|
pass |