summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2012-07-18 20:48:08 -0400
committerGravatar Joey Hess <joey@kitenet.net>2012-07-18 20:48:08 -0400
commit549f8619998eab17aaf2122f11f036fac7e6cc40 (patch)
treefe04e7cc354e13a0b508dab25f0611aeb14d5042
parent2edb5d145c66c36d0f5fd90bfb7905989643266a (diff)
fix parsing of startedTime
-rw-r--r--Logs/Transfer.hs12
1 files changed, 7 insertions, 5 deletions
diff --git a/Logs/Transfer.hs b/Logs/Transfer.hs
index 1e3d0abdb..b6962262d 100644
--- a/Logs/Transfer.hs
+++ b/Logs/Transfer.hs
@@ -118,7 +118,7 @@ checkTransfer t = do
case locked of
Nothing -> return Nothing
Just (pid, _) -> liftIO $
- flip catchDefaultIO Nothing $
+ flip catchDefaultIO Nothing $ do
readTransferInfo pid
<$> readFile tfile
@@ -163,7 +163,7 @@ writeTransferInfo :: TransferInfo -> String
writeTransferInfo info = unlines
-- transferPid is not included; instead obtained by looking at
-- the process that locks the file.
- [ show $ startedTime info
+ [ maybe "" show $ startedTime info
-- bytesComplete is not included; changes too fast
, fromMaybe "" $ associatedFile info -- comes last; arbitrary content
]
@@ -172,7 +172,7 @@ readTransferInfo :: ProcessID -> String -> Maybe TransferInfo
readTransferInfo pid s =
case bits of
[time] -> TransferInfo
- <$> parsetime time
+ <$> (Just <$> parsePOSIXTime time)
<*> pure (Just pid)
<*> pure Nothing
<*> pure Nothing
@@ -182,5 +182,7 @@ readTransferInfo pid s =
where
(bits, filebits) = splitAt 1 $ lines s
filename = join "\n" filebits
- parsetime t = Just . utcTimeToPOSIXSeconds
- <$> parseTime defaultTimeLocale "%s%Qs" t
+
+parsePOSIXTime :: String -> Maybe POSIXTime
+parsePOSIXTime s = utcTimeToPOSIXSeconds
+ <$> parseTime defaultTimeLocale "%s%Qs" s