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.
This commit is contained in:
Joey Hess 2012-10-24 10:59:25 -04:00
parent c396b9f542
commit c6fbed48a1
2 changed files with 10 additions and 4 deletions

View file

@ -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 - If the transfer action returns False, the transfer info is
- left in the failedTransferDir. - 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 :: Transfer -> Maybe FilePath -> RetryDecider -> (MeterUpdate -> Annex Bool) -> Annex Bool
runTransfer t file shouldretry a = do runTransfer t file shouldretry a = do
@ -107,7 +110,7 @@ runTransfer t file shouldretry a = do
unless ok $ failed info unless ok $ failed info
return ok return ok
where where
prep tfile mode info = do prep tfile mode info = catchMaybeIO $ do
fd <- openFd (transferLockFile tfile) ReadWrite (Just mode) fd <- openFd (transferLockFile tfile) ReadWrite (Just mode)
defaultFileFlags { trunc = True } defaultFileFlags { trunc = True }
locked <- catchMaybeIO $ locked <- catchMaybeIO $
@ -116,7 +119,8 @@ runTransfer t file shouldretry a = do
error $ "transfer already in progress" error $ "transfer already in progress"
writeTransferInfoFile info tfile writeTransferInfoFile info tfile
return fd return fd
cleanup tfile fd = do cleanup _ Nothing = noop
cleanup tfile (Just fd) = do
void $ tryIO $ removeFile tfile void $ tryIO $ removeFile tfile
void $ tryIO $ removeFile $ transferLockFile tfile void $ tryIO $ removeFile $ transferLockFile tfile
closeFd fd closeFd fd
@ -149,7 +153,7 @@ runTransfer t file shouldretry a = do
mkProgressUpdater :: Transfer -> TransferInfo -> Annex (MeterUpdate, FilePath, MVar Integer) mkProgressUpdater :: Transfer -> TransferInfo -> Annex (MeterUpdate, FilePath, MVar Integer)
mkProgressUpdater t info = do mkProgressUpdater t info = do
tfile <- fromRepo $ transferFile t tfile <- fromRepo $ transferFile t
createAnnexDirectory $ takeDirectory tfile _ <- tryAnnex $ createAnnexDirectory $ takeDirectory tfile
mvar <- liftIO $ newMVar 0 mvar <- liftIO $ newMVar 0
return (liftIO . updater tfile mvar, tfile, mvar) return (liftIO . updater tfile mvar, tfile, mvar)
where where
@ -157,7 +161,7 @@ mkProgressUpdater t info = do
if (bytes - oldbytes >= mindelta) if (bytes - oldbytes >= mindelta)
then do then do
let info' = info { bytesComplete = Just bytes } let info' = info { bytesComplete = Just bytes }
writeTransferInfoFile info' tfile _ <- tryIO $ writeTransferInfoFile info' tfile
return bytes return bytes
else return oldbytes else return oldbytes
{- The minimum change in bytesComplete that is worth {- The minimum change in bytesComplete that is worth

2
debian/changelog vendored
View file

@ -19,6 +19,8 @@ git-annex (3.20121018) UNRELEASED; urgency=low
* webapp: Switched to using the same multicast IP address that avahi uses. * webapp: Switched to using the same multicast IP address that avahi uses.
* bup: Don't pass - to bup-split to make it read stdin; bup 0.25 * bup: Don't pass - to bup-split to make it read stdin; bup 0.25
does not accept that. does not accept that.
* bugfix: Don't fail transferring content from read-only repos.
Closes: #691341
-- Joey Hess <joeyh@debian.org> Wed, 17 Oct 2012 14:24:10 -0400 -- Joey Hess <joeyh@debian.org> Wed, 17 Oct 2012 14:24:10 -0400