diff options
author | Joey Hess <joey@kitenet.net> | 2013-03-18 20:34:56 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2013-03-18 20:40:24 -0400 |
commit | 9acd2ee80f357d34eee7335f775b47bec87f4aed (patch) | |
tree | 929d65ca08975e520e90b8fe89ffa4d9dafee46a /Logs | |
parent | f4bb9f0168e8318f78069406b98b3fca10839242 (diff) |
optimisation for transfers to drives that are not plugged in
Rather than forking a git-annex transferkey only to have it fail,
just immediately record the failed transfer (so when the drive is plugged
in, the scan will retry it).
Diffstat (limited to 'Logs')
-rw-r--r-- | Logs/Transfer.hs | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/Logs/Transfer.hs b/Logs/Transfer.hs index 6d6d3d890..c6f240be0 100644 --- a/Logs/Transfer.hs +++ b/Logs/Transfer.hs @@ -115,7 +115,7 @@ runTransfer t file shouldretry a = do mode <- annexFileMode ok <- retry info metervar $ bracketIO (prep tfile mode info) (cleanup tfile) (a meter) - unless ok $ failed info + unless ok $ recordFailedTransfer t info return ok where prep tfile mode info = catchMaybeIO $ do @@ -132,10 +132,6 @@ runTransfer t file shouldretry a = do void $ tryIO $ removeFile tfile void $ tryIO $ removeFile $ transferLockFile tfile closeFd fd - failed info = do - failedtfile <- fromRepo $ failedTransferFile t - createAnnexDirectory $ takeDirectory failedtfile - liftIO $ writeTransferInfoFile info failedtfile retry oldinfo metervar run = do v <- tryAnnex run case v of @@ -236,6 +232,12 @@ removeFailedTransfer t = do f <- fromRepo $ failedTransferFile t liftIO $ void $ tryIO $ removeFile f +recordFailedTransfer :: Transfer -> TransferInfo -> Annex () +recordFailedTransfer t info = do + failedtfile <- fromRepo $ failedTransferFile t + createAnnexDirectory $ takeDirectory failedtfile + liftIO $ writeTransferInfoFile info failedtfile + {- The transfer information file to use for a given Transfer. -} transferFile :: Transfer -> Git.Repo -> FilePath transferFile (Transfer direction u key) r = transferDir direction r |