feat: 增加 /api/files/exists 与 /api/files/register-sftp 接口
- DAO 增加 get_by_sha256
- UploadService 抽出 _to_response 复用;新增 find_by_sha256、register_sftp
- 控制器新增两条路由(注意排在 /{file_id} 之前以避免被吞)
- 引入 SftpRegisterRequest schema
- SFTP 服务启动时自动创建 uploads/incoming/
- 行为:路径穿越 400、文件不存在 404、sha256 已存在则去重返回已有行
This commit is contained in:
@@ -21,6 +21,10 @@ class UploadedFileDAO:
|
||||
def get_by_id(self, file_id: int) -> UploadedFile | None:
|
||||
return self.db.get(UploadedFile, file_id)
|
||||
|
||||
def get_by_sha256(self, sha256: str) -> UploadedFile | None:
|
||||
stmt = select(UploadedFile).where(UploadedFile.sha256 == sha256).limit(1)
|
||||
return self.db.scalars(stmt).first()
|
||||
|
||||
def list(self, limit: int = 100, offset: int = 0) -> list[UploadedFile]:
|
||||
stmt = (
|
||||
select(UploadedFile)
|
||||
|
||||
Reference in New Issue
Block a user