summaryrefslogtreecommitdiff
path: root/Logs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2017-03-10 13:12:24 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2017-03-10 13:35:31 -0400
commit8cb9381befed4174624edfc80e09185c9340b4f6 (patch)
treee5d2041ff38502b1f8a5ef9caa6515cccfcea555 /Logs
parente230fd58b5f5d5d16f87e1bd5c0f2e553f2ae5a2 (diff)
AssociatedFile newtype
To prevent any further mistakes like 1a497cefb47557f0b4788c606f9071be422b2511 This commit was sponsored by Francois Marier on Patreon.
Diffstat (limited to 'Logs')
-rw-r--r--Logs/Transfer.hs17
1 files changed, 11 insertions, 6 deletions
diff --git a/Logs/Transfer.hs b/Logs/Transfer.hs
index ce2a7d299..aef233b77 100644
--- a/Logs/Transfer.hs
+++ b/Logs/Transfer.hs
@@ -10,6 +10,7 @@
module Logs.Transfer where
import Types.Transfer
+import Types.ActionItem
import Annex.Common
import Annex.Perms
import qualified Git
@@ -27,7 +28,9 @@ describeTransfer :: Transfer -> TransferInfo -> String
describeTransfer t info = unwords
[ show $ transferDirection t
, show $ transferUUID t
- , fromMaybe (key2file $ transferKey t) (associatedFile info)
+ , actionItemDesc
+ (ActionItemAssociatedFile (associatedFile info))
+ (transferKey t)
, show $ bytesComplete info
]
@@ -67,8 +70,8 @@ mkProgressUpdater t info = do
Just sz -> sz `div` 100
Nothing -> 100 * 1024 -- arbitrarily, 100 kb
-startTransferInfo :: Maybe FilePath -> IO TransferInfo
-startTransferInfo file = TransferInfo
+startTransferInfo :: AssociatedFile -> IO TransferInfo
+startTransferInfo afile = TransferInfo
<$> (Just . utcTimeToPOSIXSeconds <$> getCurrentTime)
#ifndef mingw32_HOST_OS
<*> pure Nothing -- pid not stored in file, so omitted for speed
@@ -78,7 +81,7 @@ startTransferInfo file = TransferInfo
<*> pure Nothing -- tid ditto
<*> pure Nothing -- not 0; transfer may be resuming
<*> pure Nothing
- <*> pure file
+ <*> pure afile
<*> pure False
{- If a transfer is still running, returns its TransferInfo.
@@ -228,7 +231,9 @@ writeTransferInfo info = unlines
#ifdef mingw32_HOST_OS
, maybe "" show (transferPid info)
#endif
- , fromMaybe "" $ associatedFile info -- comes last; arbitrary content
+ -- comes last; arbitrary content
+ , let AssociatedFile afile = associatedFile info
+ in fromMaybe "" afile
]
readTransferInfoFile :: Maybe PID -> FilePath -> IO (Maybe TransferInfo)
@@ -246,7 +251,7 @@ readTransferInfo mpid s = TransferInfo
<*> pure Nothing
<*> pure Nothing
<*> bytes
- <*> pure (if null filename then Nothing else Just filename)
+ <*> pure (AssociatedFile (if null filename then Nothing else Just filename))
<*> pure False
where
#ifdef mingw32_HOST_OS