Skip to content

Commit

Permalink
fix: bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
githubering182 committed Mar 11, 2024
1 parent 677cc4f commit ef2bd41
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
4 changes: 2 additions & 2 deletions frontend-app/src/components/ui/FileMedia/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ var handleMediaFallback = ({ target }) => {

// TODO: after this fallback controls wont show up again, fix
if (target.tagName === "VIDEO") {
//target.controls = false;
target.controls = false;
target.poster = fallbackSrc;
}
else target.src = fallbackSrc;
Expand Down Expand Up @@ -58,7 +58,7 @@ function FileMedia({ files, slide, pathID }, ref) {
onError={(e) => handleMediaFallback(e)}
/>
: <img alt="validation_item" {...props} onError={(e) => handleMediaFallback(e)} />;
}, [typeVideo]);
}, [fileUrl]);

let scale = 1,
panning = false,
Expand Down
16 changes: 10 additions & 6 deletions storage-app/src/shared/app_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def _stream_file(self, request: Request) -> StreamingResponse:

response: StreamingResponse = StreamingResponse(
self._iterator(),
status_code=(206 if self.range_match else 200),
status_code=206,
media_type=self.content_type
)

Expand All @@ -89,8 +89,10 @@ async def _iterator(self) -> AsyncGenerator[bytes, None]:
self.file.seek(self.chunk_start)
remaining: int = self.chunk_length

while remaining and (chunk := await self.file.read(CHUNK_SIZE)):
remaining -= CHUNK_SIZE if CHUNK_SIZE <= remaining else remaining
while remaining and (
chunk := await self.file.read(read := min(CHUNK_SIZE, remaining))
):
remaining -= read
yield chunk
else: self.file.close()

Expand All @@ -115,9 +117,11 @@ def _set_chunks(self) -> None:
)

chunk_start = int(chunk_start)
chunk_end = int(chunk_end) if chunk_end else self.file.length

if chunk_end >= self.file.length: chunk_end = self.file.length - 1
chunk_end = (
_end
if chunk_end and (_end := int(chunk_end)) < self.file.length
else self.file.length - 1
)

chunk_length: int = chunk_end - chunk_start + 1

Expand Down
2 changes: 1 addition & 1 deletion storage-app/src/shared/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
BROKER_URL: str | None = getenv("CELERY_BROKER_URL")
RESULT_URL: str | None = BROKER_URL

CHUNK_SIZE: int = 1024 * int(1024 / 2)
CHUNK_SIZE: int = 1024 * 512

DB_STORAGE: str = "storage"

Expand Down

0 comments on commit ef2bd41

Please sign in to comment.