summaryrefslogtreecommitdiff
path: root/Logs/Transfer.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2012-08-29 15:24:09 -0400
committerGravatar Joey Hess <joey@kitenet.net>2012-08-29 15:24:09 -0400
commit99525f8454ecdcc41b37d8fcae83502ea5044d43 (patch)
treee0e5d0b20fd0e4556fb6d23a3e62a97d3a229319 /Logs/Transfer.hs
parent9e54355e8b6751f6ce786da480566e27fb5996d8 (diff)
when canceling a transfer, also cancel all other downloads of the same key
Diffstat (limited to 'Logs/Transfer.hs')
-rw-r--r--Logs/Transfer.hs7
1 files changed, 7 insertions, 0 deletions
diff --git a/Logs/Transfer.hs b/Logs/Transfer.hs
index 642ee7ea1..ea56035d1 100644
--- a/Logs/Transfer.hs
+++ b/Logs/Transfer.hs
@@ -60,6 +60,13 @@ readLcDirection "upload" = Just Upload
readLcDirection "download" = Just Download
readLcDirection _ = Nothing
+{- Transfers that will accomplish the same task. -}
+equivilantTransfer :: Transfer -> Transfer -> Bool
+equivilantTransfer t1 t2
+ | transferDirection t1 == Download && transferDirection t2 == Download &&
+ transferUUID t1 == transferUUID t2 = True
+ | otherwise = t1 == t2
+
percentComplete :: Transfer -> TransferInfo -> Maybe Percentage
percentComplete (Transfer { transferKey = key }) info =
percentage <$> keySize key <*> Just (fromMaybe 0 $ bytesComplete info)