ruff + mypy pass
This commit is contained in:
parent
607213f1c4
commit
f4fbfa3155
3 changed files with 9 additions and 21 deletions
|
@ -1,5 +1,4 @@
|
|||
from sqlalchemy import MetaData, Table, Column, Integer, String, ForeignKey
|
||||
from sqlalchemy.ext.declarative import declarative_base
|
||||
from sqlalchemy import Column, Integer, String, ForeignKey
|
||||
from sqlalchemy.orm import DeclarativeBase, relationship, Mapped, mapped_column
|
||||
|
||||
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
import os
|
||||
from pathlib import Path
|
||||
from typing import Annotated
|
||||
import datetime
|
||||
|
@ -6,13 +5,12 @@ import aiofiles
|
|||
import tempfile
|
||||
import hashlib
|
||||
|
||||
import toml
|
||||
import magic
|
||||
|
||||
import sqlalchemy.exc
|
||||
from sqlalchemy import create_engine
|
||||
from sqlalchemy.orm import sessionmaker
|
||||
from fastapi import FastAPI, UploadFile, File, Header, Form, HTTPException
|
||||
from fastapi import FastAPI, UploadFile, Header, Form, HTTPException
|
||||
from fastapi.requests import Request
|
||||
from fastapi.responses import RedirectResponse
|
||||
from fastapi.templating import Jinja2Templates
|
||||
|
@ -91,7 +89,7 @@ async def upload(
|
|||
conn.add(orig)
|
||||
try:
|
||||
conn.commit()
|
||||
except sqlalchemy.exc.IntegrityError as exc:
|
||||
except sqlalchemy.exc.IntegrityError:
|
||||
conn.rollback()
|
||||
conflicting = (
|
||||
conn.query(database.Original)
|
||||
|
@ -104,18 +102,19 @@ async def upload(
|
|||
detail = "File is already in the archive"
|
||||
raise HTTPException(status_code=400, detail=detail)
|
||||
conn.refresh(orig)
|
||||
data = {
|
||||
|
||||
output_data = {
|
||||
"id": orig.id,
|
||||
"path": orig.filepath,
|
||||
"url": CONFIG["public"]["baseurl"] + "/dl/" + orig.filepath,
|
||||
}
|
||||
if "application/json" in request.headers.get("accept", ""):
|
||||
return data
|
||||
return output_data
|
||||
else:
|
||||
return templates.TemplateResponse(
|
||||
name="ok.html", request=request, context=data
|
||||
name="ok.html", request=request, context=output_data
|
||||
)
|
||||
except Exception as exc:
|
||||
except Exception:
|
||||
Path(temp.name).unlink()
|
||||
raise
|
||||
|
||||
|
|
|
@ -1,22 +1,12 @@
|
|||
import os
|
||||
from pathlib import Path
|
||||
from typing import Annotated
|
||||
import datetime
|
||||
import aiofiles
|
||||
import tempfile
|
||||
import hashlib
|
||||
|
||||
import magic
|
||||
|
||||
from sqlalchemy import create_engine
|
||||
from sqlalchemy.orm import sessionmaker, joinedload
|
||||
from fastapi import FastAPI, HTTPException
|
||||
from fastapi.requests import Request
|
||||
from fastapi.responses import RedirectResponse, FileResponse
|
||||
from fastapi.templating import Jinja2Templates
|
||||
from pydantic import BaseModel
|
||||
|
||||
from caricari.httpcommon import ProxyInfo, get_config
|
||||
from caricari.httpcommon import get_config
|
||||
from caricari import database
|
||||
|
||||
CONFIG = get_config()
|
||||
|
|
Loading…
Reference in a new issue