diff options
Diffstat (limited to 'Logs/Transfer.hs')
-rw-r--r-- | Logs/Transfer.hs | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/Logs/Transfer.hs b/Logs/Transfer.hs index 5072ca9aa..d7e25b936 100644 --- a/Logs/Transfer.hs +++ b/Logs/Transfer.hs @@ -118,14 +118,16 @@ runTransfer t file shouldretry a = do info <- liftIO $ startTransferInfo file (meter, tfile, metervar) <- mkProgressUpdater t info mode <- annexFileMode - (fd, cantransfer) <- liftIO $ prep tfile mode info - if cantransfer + (fd, inprogress) <- liftIO $ prep tfile mode info + if inprogress then do + showNote "transfer already in progress" + return False + else do ok <- retry info metervar $ bracketIO (return fd) (cleanup tfile) (const $ a meter) unless ok $ recordFailedTransfer t info return ok - else return False where prep tfile mode info = do #ifndef __WINDOWS__ @@ -133,22 +135,20 @@ runTransfer t file shouldretry a = do openFd (transferLockFile tfile) ReadWrite (Just mode) defaultFileFlags { trunc = True } case mfd of - Nothing -> return (mfd, True) + Nothing -> return (mfd, False) Just fd -> do locked <- catchMaybeIO $ setLock fd (WriteLock, AbsoluteSeek, 0, 0) if isNothing locked - then do - hPutStrLn stderr "transfer already in progress" - return (Nothing, False) + then return (Nothing, True) else do void $ tryIO $ writeTransferInfoFile info tfile - return (mfd, True) + return (mfd, False) #else mfd <- catchMaybeIO $ do writeFile (transferLockFile tfile) "" writeTransferInfoFile info tfile - return (mfd, True) + return (mfd, False) #endif cleanup _ Nothing = noop cleanup tfile (Just fd) = do |