-
-
Notifications
You must be signed in to change notification settings - Fork 368
feat: downloads storage manager tab #878
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
Changes from 25 commits
a5dfbb1
d05ce1e
cb6e979
aa9e92a
3a8a03e
f62d3e0
11a80c4
94aa7b1
d579277
3bca522
fa86c33
9ecbfd2
ea6c9fd
cac5164
800d134
0b65053
c4d58d4
23749c3
9833f61
646fd66
7fc4416
7ebc53e
81341c3
83dde8d
ee1c6f2
274240d
b320045
fe422a8
780bb31
193c451
fd3d2ed
0ec73b7
79841f9
1525e13
611c1b2
96ff5ae
a1c6ea3
d43a6d9
508333b
8a067ac
f5e607e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -189,6 +189,40 @@ data class DownloadInfo( | |
| } | ||
| } | ||
|
|
||
| /** | ||
| * Returns the recent download speed in bytes per second, or null if there is | ||
| * not enough sample data yet. | ||
| */ | ||
| fun getCurrentDownloadSpeed(windowSeconds: Int = 10): Long? { | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We shouldn't do this - there's already code to calculate speed in
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removed, will look at consolidating a shared helper later on but for now exempting speed from dl view |
||
| if (!isActive) return null | ||
|
|
||
| val now = System.currentTimeMillis() | ||
| val cutoff = now - windowSeconds * 1000L | ||
| val samples = speedSamples.toTypedArray().filter { it.timeMs >= cutoff }.toList() | ||
| if (samples.size < 2) { | ||
| return emaSpeedBytesPerSec.takeIf { hasEmaSpeed && it > 0.0 }?.toLong() | ||
|
xXJSONDeruloXx marked this conversation as resolved.
Outdated
|
||
| } | ||
|
|
||
| val first = samples.first() | ||
| val last = samples.last() | ||
| val elapsedMs = last.timeMs - first.timeMs | ||
| if (elapsedMs <= 0L) { | ||
| return emaSpeedBytesPerSec.takeIf { hasEmaSpeed && it > 0.0 }?.toLong() | ||
| } | ||
|
|
||
| val bytesDelta = last.bytes - first.bytes | ||
| if (bytesDelta <= 0L) { | ||
| return emaSpeedBytesPerSec.takeIf { hasEmaSpeed && it > 0.0 }?.toLong() | ||
| } | ||
|
|
||
| val bytesPerSecond = bytesDelta.toDouble() / (elapsedMs.toDouble() / 1000.0) | ||
| if (bytesPerSecond <= 0.0 || bytesPerSecond.isNaN() || bytesPerSecond.isInfinite()) { | ||
| return emaSpeedBytesPerSec.takeIf { hasEmaSpeed && it > 0.0 }?.toLong() | ||
| } | ||
|
|
||
| return bytesPerSecond.toLong() | ||
| } | ||
|
|
||
| /** | ||
| * Returns an ETA in milliseconds based on recent download speed, or null if | ||
| * there is not enough information yet (e.g. just started) or download is inactive. | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's this? doesn't seem like we should be adding this, we should track partial installs the same way we do for GOG, Epic, Steam. No need to add a new column.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nvm, I just saw that we're adding this column for GOG and Epic also. Are you sure this is necessary? We can already track partial installs by looking for the .DOWNLOAD_COMPLETED marker. We already do it in several places. I understand that it might be needed as a quick query, but this DB marker seems like something that will get out of sync
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah we can just use download completed in marker utils and that lets us remove the room increment and db changes. Done