Merge pull request #1201 from rommapp/rom-upload-proxy-buffering

Bypass nginx proxy buffering when uploading roms
This commit is contained in:
Georges-Antoine Assi
2024-09-21 12:22:35 -04:00
committed by GitHub
4 changed files with 15 additions and 7 deletions

View File

@@ -165,15 +165,19 @@ class SimpleRomSchema(RomSchema):
rom_user: RomUserSchema
@classmethod
def from_orm_with_request(
cls, db_rom: Rom, request: Request
) -> SimpleRomSchema | None:
def from_orm_with_request(cls, db_rom: Rom, request: Request) -> SimpleRomSchema:
user_id = request.user.id
db_rom.rom_user = RomUserSchema.for_user(user_id, db_rom)
return cls.model_validate(db_rom)
@classmethod
def from_orm_with_factory(cls, db_rom: Rom) -> SimpleRomSchema:
db_rom.rom_user = rom_user_schema_factory()
return cls.model_validate(db_rom)
class DetailedRomSchema(RomSchema):
merged_screenshots: list[str]

View File

@@ -373,7 +373,7 @@ async def _identify_rom(
{
"platform_name": platform.name,
"platform_slug": platform.slug,
**SimpleRomSchema.model_validate(_added_rom).model_dump(
**SimpleRomSchema.from_orm_with_factory(_added_rom).model_dump(
exclude={"created_at", "updated_at", "rom_user"}
),
},

View File

@@ -21,8 +21,9 @@ http {
client_max_body_size 0;
client_header_buffer_size 1k;
large_client_header_buffers 4 16k;
send_timeout 60s;
keepalive_timeout 65s;
send_timeout 600s;
keepalive_timeout 600s;
client_body_timeout 600s;
tcp_nopush on;
tcp_nodelay on;
@@ -97,6 +98,8 @@ http {
# Backend api calls
location /api {
proxy_pass http://wsgi_server;
proxy_request_buffering off;
proxy_buffering off;
}
location /ws {
proxy_pass http://wsgi_server;

View File

@@ -32,10 +32,11 @@ async function uploadRoms({
api
.post("/roms", formData, {
headers: {
"Content-Type": "multipart/form-data; boundary=boundary",
"Content-Type": "multipart/form-data",
"X-Upload-Platform": platformId.toString(),
"X-Upload-Filename": file.name,
},
timeout: 600000,
params: {},
onUploadProgress: (progressEvent: AxiosProgressEvent) => {
uploadStore.update(file.name, progressEvent);