aboutsummaryrefslogtreecommitdiff
path: root/Hotline/Library/NetSocket/TransferRateEstimator.swift
diff options
context:
space:
mode:
authorDustin Mierau <dustin@mierau.me>2025-11-11 15:39:02 -0800
committerDustin Mierau <dustin@mierau.me>2025-11-11 15:39:02 -0800
commitf87ff05d17cedf21845abbb8d750759ba725a263 (patch)
tree154feff5eed1b3f7787eeb2f743ffe6602b6cd31 /Hotline/Library/NetSocket/TransferRateEstimator.swift
parentcdaff85ac22f45e39ab1f02474beaa7aada9ad9b (diff)
Folder download logic cleanup. Display folder icon on folder download transfers with small icon for the current file. Fix progress for folder downloads.
Diffstat (limited to 'Hotline/Library/NetSocket/TransferRateEstimator.swift')
-rw-r--r--Hotline/Library/NetSocket/TransferRateEstimator.swift3
1 files changed, 3 insertions, 0 deletions
diff --git a/Hotline/Library/NetSocket/TransferRateEstimator.swift b/Hotline/Library/NetSocket/TransferRateEstimator.swift
index badf87a..61383ff 100644
--- a/Hotline/Library/NetSocket/TransferRateEstimator.swift
+++ b/Hotline/Library/NetSocket/TransferRateEstimator.swift
@@ -70,6 +70,7 @@ public struct TransferRateEstimator {
self.minSamples = minSamples
}
+ @discardableResult
public mutating func update(total: Int) -> NetSocket.FileProgress {
return self.update(bytes: max(0, total - self.transferred))
}
@@ -80,6 +81,7 @@ public struct TransferRateEstimator {
///
/// - Parameter bytes: Number of bytes transferred in this sample
/// - Returns: Current progress with speed and ETA estimates
+ @discardableResult
public mutating func update(bytes: Int) -> NetSocket.FileProgress {
let clock = ContinuousClock()
let now = clock.now
@@ -127,6 +129,7 @@ public struct TransferRateEstimator {
return NetSocket.FileProgress(
sent: self.transferred,
total: self.total,
+ now: bytes,
bytesPerSecond: haveEstimate ? self.emaBytesPerSecond : nil,
estimatedTimeRemaining: eta
)