diff options
author | Joey Hess <joey@kitenet.net> | 2012-07-18 18:42:41 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2012-07-18 18:42:41 -0400 |
commit | eea0a3616cd1cbaf033649c11a5c2b650b6b632f (patch) | |
tree | 301720ffb8cef64907d798893ab5f53fc9bc904b /Logs/Transfer.hs | |
parent | f520a2c10359257ea6f920d26fe29831db8d07e3 (diff) |
add thread id field to transferinfo
Also converted its timestand to posix seconds, like is used in the other
log files.
Diffstat (limited to 'Logs/Transfer.hs')
-rw-r--r-- | Logs/Transfer.hs | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/Logs/Transfer.hs b/Logs/Transfer.hs index 260512067..f74d128dc 100644 --- a/Logs/Transfer.hs +++ b/Logs/Transfer.hs @@ -16,6 +16,10 @@ import qualified Fields import System.Posix.Types import Data.Time.Clock +import Data.Time.Clock.POSIX +import Data.Time +import System.Locale +import Control.Concurrent {- Enough information to uniquely identify a transfer, used as the filename - of the transfer information file. -} @@ -33,8 +37,9 @@ data Transfer = Transfer - of some repository, that was acted on to initiate the transfer. -} data TransferInfo = TransferInfo - { startedTime :: Maybe UTCTime + { startedTime :: Maybe POSIXTime , transferPid :: Maybe ProcessID + , transferTid :: Maybe ThreadId , transferRemote :: Maybe Remote , bytesComplete :: Maybe Integer , associatedFile :: Maybe FilePath @@ -76,8 +81,9 @@ transfer t file a = do createAnnexDirectory $ takeDirectory tfile mode <- annexFileMode info <- liftIO $ TransferInfo - <$> (Just <$> getCurrentTime) + <$> (Just . utcTimeToPOSIXSeconds <$> getCurrentTime) <*> pure Nothing -- pid not stored in file, so omitted for speed + <*> pure Nothing -- tid ditto <*> pure Nothing -- not 0; transfer may be resuming <*> pure Nothing <*> pure file @@ -168,13 +174,16 @@ readTransferInfo :: ProcessID -> String -> Maybe TransferInfo readTransferInfo pid s = case bits of [time] -> TransferInfo - <$> readish time + <$> parsetime time <*> pure (Just pid) <*> pure Nothing <*> pure Nothing + <*> pure Nothing <*> pure (if null filename then Nothing else Just filename) <*> pure False _ -> Nothing where (bits, filebits) = splitAt 1 $ lines s filename = join "\n" filebits + parsetime t = Just . utcTimeToPOSIXSeconds + <$> parseTime defaultTimeLocale "%s%Qs" t |