Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIx] Edge case where downloaded size is bigger than download size #1259

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions src/frontend/components/UI/DownloadToastManager/index.tsx
Original file line number Diff line number Diff line change
@@ -14,6 +14,7 @@ import DMQueueState from 'frontend/state/DMQueueState'
import { isNotNative } from 'frontend/helpers/library'
import { hasProgress } from 'frontend/hooks/hasProgress'
import { useGameInfo } from 'frontend/hooks/useGameInfo'
import { useEstimatedUncompressedSize } from 'frontend/hooks/useEstimatedUncompressedSize'

export default function DownloadToastManager() {
const [latestElement, setLatestElement] = useState<DMQueueElement>()
@@ -37,6 +38,7 @@ export default function DownloadToastManager() {
const installedPlatform = currentElement?.params.platformToInstall
const isExtracting = status === 'extracting'
const isPatching = status === 'patching'
const isInstalling = status === 'installing'
const { progress, etaInMs } = hasProgress(appName, isExtracting)

let showPlayTimeout: NodeJS.Timeout | undefined = undefined
@@ -160,9 +162,22 @@ export default function DownloadToastManager() {
return 'inProgress'
}

const adjustedDownloadedInBytes = downloadedMB * 1024 * 1024
const adjustedDownloadSizeInBytes =
progress.totalSize || installInfo?.manifest.download_size || 0
const uncompressedSize = useEstimatedUncompressedSize(
platform,
installInfo?.manifest?.disk_size || 0,
installInfo?.manifest?.download_size || 0
)

let adjustedDownloadedInBytes = downloadedMB * 1024 * 1024
const adjustedDownloadSizeInBytes = isInstalling
? installInfo?.manifest.download_size || 0
: uncompressedSize

if (isExtracting) {
if (adjustedDownloadedInBytes > adjustedDownloadSizeInBytes) {
adjustedDownloadedInBytes = adjustedDownloadSizeInBytes
}
}

return (
<Draggable>