api: _sha256 补类型注解 str|Path
This commit is contained in:
@@ -12,6 +12,7 @@ API 层 (api)
|
||||
"""
|
||||
|
||||
import hashlib
|
||||
from pathlib import Path
|
||||
|
||||
from fastapi import FastAPI, Request
|
||||
from fastapi.responses import JSONResponse
|
||||
@@ -39,7 +40,7 @@ storage = Storage(tasks, STORAGE_ROOT)
|
||||
app = FastAPI(title="7z-encrypt 服务端")
|
||||
|
||||
|
||||
def _sha256(path) -> str:
|
||||
def _sha256(path: str | Path) -> str:
|
||||
h = hashlib.sha256()
|
||||
with open(path, "rb") as f:
|
||||
for chunk in iter(lambda: f.read(1 << 20), b""):
|
||||
|
||||
Reference in New Issue
Block a user