summaryrefslogtreecommitdiff
path: root/Logs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2012-10-24 10:59:25 -0400
committerGravatar Joey Hess <joey@kitenet.net>2012-10-24 10:59:25 -0400
commita2a4070c6547119e3aea7a6b5be8d0345b2b2904 (patch)
tree260f4755da11a777cc597ef35dc3a66f015e8591 /Logs
parent04b9ddb0c6a4f8e18622b86bc981a61b99150174 (diff)
bugfix: Don't fail transferring content from read-only repos. Closes: #691341
This used to work, but got broken when the transfer info files were added, as it failed writing them on the readonly filesystem.
Diffstat (limited to 'Logs')
-rw-r--r--Logs/Transfer.hs12
1 files changed, 8 insertions, 4 deletions
diff --git a/Logs/Transfer.hs b/Logs/Transfer.hs
index e9922422f..99b5a9bba 100644
--- a/Logs/Transfer.hs
+++ b/Logs/Transfer.hs
@@ -96,6 +96,9 @@ download u key file shouldretry a = runTransfer (Transfer Download u key) file s
-
- If the transfer action returns False, the transfer info is
- left in the failedTransferDir.
+ -
+ - An upload can be run from a read-only filesystem, and in this case
+ - no transfer information or lock file is used.
-}
runTransfer :: Transfer -> Maybe FilePath -> RetryDecider -> (MeterUpdate -> Annex Bool) -> Annex Bool
runTransfer t file shouldretry a = do
@@ -107,7 +110,7 @@ runTransfer t file shouldretry a = do
unless ok $ failed info
return ok
where
- prep tfile mode info = do
+ prep tfile mode info = catchMaybeIO $ do
fd <- openFd (transferLockFile tfile) ReadWrite (Just mode)
defaultFileFlags { trunc = True }
locked <- catchMaybeIO $
@@ -116,7 +119,8 @@ runTransfer t file shouldretry a = do
error $ "transfer already in progress"
writeTransferInfoFile info tfile
return fd
- cleanup tfile fd = do
+ cleanup _ Nothing = noop
+ cleanup tfile (Just fd) = do
void $ tryIO $ removeFile tfile
void $ tryIO $ removeFile $ transferLockFile tfile
closeFd fd
@@ -149,7 +153,7 @@ runTransfer t file shouldretry a = do
mkProgressUpdater :: Transfer -> TransferInfo -> Annex (MeterUpdate, FilePath, MVar Integer)
mkProgressUpdater t info = do
tfile <- fromRepo $ transferFile t
- createAnnexDirectory $ takeDirectory tfile
+ _ <- tryAnnex $ createAnnexDirectory $ takeDirectory tfile
mvar <- liftIO $ newMVar 0
return (liftIO . updater tfile mvar, tfile, mvar)
where
@@ -157,7 +161,7 @@ mkProgressUpdater t info = do
if (bytes - oldbytes >= mindelta)
then do
let info' = info { bytesComplete = Just bytes }
- writeTransferInfoFile info' tfile
+ _ <- tryIO $ writeTransferInfoFile info' tfile
return bytes
else return oldbytes
{- The minimum change in bytesComplete that is worth