Avoid accumulating transfer failure log files unless the assistant is being used.
Only the assistant uses these, and only the assistant cleans them up, so make only git annex transferkeys write them, There is one behavior change from this. If glacier is being used, and a manual git annex get --from glacier fails because the file isn't available yet, the assistant will no longer later see that failed transfer file and retry the get. Hope no-one depended on that old behavior.
This commit is contained in:
parent
a812d598ef
commit
61ccf95004
9 changed files with 38 additions and 23 deletions
|
@ -9,6 +9,7 @@
|
||||||
|
|
||||||
module Annex.Transfer (
|
module Annex.Transfer (
|
||||||
module X,
|
module X,
|
||||||
|
noObserver,
|
||||||
upload,
|
upload,
|
||||||
download,
|
download,
|
||||||
runTransfer,
|
runTransfer,
|
||||||
|
@ -28,11 +29,18 @@ import Utility.LockFile
|
||||||
|
|
||||||
import Control.Concurrent
|
import Control.Concurrent
|
||||||
|
|
||||||
upload :: UUID -> Key -> AssociatedFile -> RetryDecider -> (MeterUpdate -> Annex Bool) -> NotifyWitness -> Annex Bool
|
type TransferAction = MeterUpdate -> Annex Bool
|
||||||
upload u key f d a _witness = runTransfer (Transfer Upload u key) f d a
|
|
||||||
|
|
||||||
download :: UUID -> Key -> AssociatedFile -> RetryDecider -> (MeterUpdate -> Annex Bool) -> NotifyWitness -> Annex Bool
|
type TransferObserver = Bool -> Transfer -> TransferInfo -> Annex ()
|
||||||
download u key f d a _witness = runTransfer (Transfer Download u key) f d a
|
|
||||||
|
noObserver :: TransferObserver
|
||||||
|
noObserver _ _ _ = noop
|
||||||
|
|
||||||
|
upload :: UUID -> Key -> AssociatedFile -> RetryDecider -> TransferObserver -> TransferAction -> NotifyWitness -> Annex Bool
|
||||||
|
upload u key f d o a _witness = runTransfer (Transfer Upload u key) f d o a
|
||||||
|
|
||||||
|
download :: UUID -> Key -> AssociatedFile -> RetryDecider -> TransferObserver -> TransferAction -> NotifyWitness -> Annex Bool
|
||||||
|
download u key f d o a _witness = runTransfer (Transfer Download u key) f d o a
|
||||||
|
|
||||||
{- Runs a transfer action. Creates and locks the lock file while the
|
{- Runs a transfer action. Creates and locks the lock file while the
|
||||||
- action is running, and stores info in the transfer information
|
- action is running, and stores info in the transfer information
|
||||||
|
@ -46,7 +54,7 @@ download u key f d a _witness = runTransfer (Transfer Download u key) f d a
|
||||||
- An upload can be run from a read-only filesystem, and in this case
|
- An upload can be run from a read-only filesystem, and in this case
|
||||||
- no transfer information or lock file is used.
|
- no transfer information or lock file is used.
|
||||||
-}
|
-}
|
||||||
runTransfer :: Transfer -> Maybe FilePath -> RetryDecider -> (MeterUpdate -> Annex Bool) -> Annex Bool
|
runTransfer :: Transfer -> Maybe FilePath -> RetryDecider -> TransferObserver -> TransferAction -> Annex Bool
|
||||||
runTransfer = runTransfer' False
|
runTransfer = runTransfer' False
|
||||||
|
|
||||||
{- Like runTransfer, but ignores any existing transfer lock file for the
|
{- Like runTransfer, but ignores any existing transfer lock file for the
|
||||||
|
@ -54,11 +62,11 @@ runTransfer = runTransfer' False
|
||||||
-
|
-
|
||||||
- Note that this may result in confusing progress meter display in the
|
- Note that this may result in confusing progress meter display in the
|
||||||
- webapp, if multiple processes are writing to the transfer info file. -}
|
- webapp, if multiple processes are writing to the transfer info file. -}
|
||||||
alwaysRunTransfer :: Transfer -> Maybe FilePath -> RetryDecider -> (MeterUpdate -> Annex Bool) -> Annex Bool
|
alwaysRunTransfer :: Transfer -> Maybe FilePath -> RetryDecider -> TransferObserver -> TransferAction -> Annex Bool
|
||||||
alwaysRunTransfer = runTransfer' True
|
alwaysRunTransfer = runTransfer' True
|
||||||
|
|
||||||
runTransfer' :: Bool -> Transfer -> Maybe FilePath -> RetryDecider -> (MeterUpdate -> Annex Bool) -> Annex Bool
|
runTransfer' :: Bool -> Transfer -> Maybe FilePath -> RetryDecider -> TransferObserver -> TransferAction -> Annex Bool
|
||||||
runTransfer' ignorelock t file shouldretry a = do
|
runTransfer' ignorelock t file shouldretry transferobserver transferaction = do
|
||||||
info <- liftIO $ startTransferInfo file
|
info <- liftIO $ startTransferInfo file
|
||||||
(meter, tfile, metervar) <- mkProgressUpdater t info
|
(meter, tfile, metervar) <- mkProgressUpdater t info
|
||||||
mode <- annexFileMode
|
mode <- annexFileMode
|
||||||
|
@ -68,9 +76,11 @@ runTransfer' ignorelock t file shouldretry a = do
|
||||||
showNote "transfer already in progress"
|
showNote "transfer already in progress"
|
||||||
return False
|
return False
|
||||||
else do
|
else do
|
||||||
ok <- retry info metervar $
|
ok <- retry info metervar $ bracketIO
|
||||||
bracketIO (return fd) (cleanup tfile) (const $ a meter)
|
(return fd)
|
||||||
unless ok $ recordFailedTransfer t info
|
(cleanup tfile)
|
||||||
|
(const $ transferaction meter)
|
||||||
|
transferobserver ok t info
|
||||||
return ok
|
return ok
|
||||||
where
|
where
|
||||||
#ifndef mingw32_HOST_OS
|
#ifndef mingw32_HOST_OS
|
||||||
|
|
|
@ -223,7 +223,7 @@ addUrlFileQuvi relaxed quviurl videourl file = do
|
||||||
tmp <- fromRepo $ gitAnnexTmpObjectLocation key
|
tmp <- fromRepo $ gitAnnexTmpObjectLocation key
|
||||||
showOutput
|
showOutput
|
||||||
ok <- Transfer.notifyTransfer Transfer.Download (Just file) $
|
ok <- Transfer.notifyTransfer Transfer.Download (Just file) $
|
||||||
Transfer.download webUUID key (Just file) Transfer.forwardRetry $ const $ do
|
Transfer.download webUUID key (Just file) Transfer.forwardRetry Transfer.noObserver $ const $ do
|
||||||
liftIO $ createDirectoryIfMissing True (parentDir tmp)
|
liftIO $ createDirectoryIfMissing True (parentDir tmp)
|
||||||
downloadUrl [videourl] tmp
|
downloadUrl [videourl] tmp
|
||||||
if ok
|
if ok
|
||||||
|
@ -297,7 +297,7 @@ downloadWith downloader dummykey u url file =
|
||||||
)
|
)
|
||||||
where
|
where
|
||||||
runtransfer tmp = Transfer.notifyTransfer Transfer.Download (Just file) $
|
runtransfer tmp = Transfer.notifyTransfer Transfer.Download (Just file) $
|
||||||
Transfer.download u dummykey (Just file) Transfer.forwardRetry $ \p -> do
|
Transfer.download u dummykey (Just file) Transfer.forwardRetry Transfer.noObserver $ \p -> do
|
||||||
liftIO $ createDirectoryIfMissing True (parentDir tmp)
|
liftIO $ createDirectoryIfMissing True (parentDir tmp)
|
||||||
downloader tmp p
|
downloader tmp p
|
||||||
|
|
||||||
|
|
|
@ -90,6 +90,6 @@ getKeyFile' key afile dest = dispatch
|
||||||
| Remote.hasKeyCheap r =
|
| Remote.hasKeyCheap r =
|
||||||
either (const False) id <$> Remote.hasKey r key
|
either (const False) id <$> Remote.hasKey r key
|
||||||
| otherwise = return True
|
| otherwise = return True
|
||||||
docopy r = download (Remote.uuid r) key afile noRetry $ \p -> do
|
docopy r = download (Remote.uuid r) key afile noRetry noObserver $ \p -> do
|
||||||
showAction $ "from " ++ Remote.name r
|
showAction $ "from " ++ Remote.name r
|
||||||
Remote.retrieveKeyFile r key afile dest p
|
Remote.retrieveKeyFile r key afile dest p
|
||||||
|
|
|
@ -95,7 +95,7 @@ toPerform dest move key afile fastcheck isthere =
|
||||||
Right False -> do
|
Right False -> do
|
||||||
showAction $ "to " ++ Remote.name dest
|
showAction $ "to " ++ Remote.name dest
|
||||||
ok <- notifyTransfer Upload afile $
|
ok <- notifyTransfer Upload afile $
|
||||||
upload (Remote.uuid dest) key afile noRetry $
|
upload (Remote.uuid dest) key afile noRetry noObserver $
|
||||||
Remote.storeKey dest key afile
|
Remote.storeKey dest key afile
|
||||||
if ok
|
if ok
|
||||||
then do
|
then do
|
||||||
|
@ -152,7 +152,7 @@ fromPerform src move key afile = ifM (inAnnex key)
|
||||||
)
|
)
|
||||||
where
|
where
|
||||||
go = notifyTransfer Download afile $
|
go = notifyTransfer Download afile $
|
||||||
download (Remote.uuid src) key afile noRetry $ \p -> do
|
download (Remote.uuid src) key afile noRetry noObserver $ \p -> do
|
||||||
showAction $ "from " ++ Remote.name src
|
showAction $ "from " ++ Remote.name src
|
||||||
getViaTmp key $ \t -> Remote.retrieveKeyFile src key afile t p
|
getViaTmp key $ \t -> Remote.retrieveKeyFile src key afile t p
|
||||||
dispatch _ False = stop -- failed
|
dispatch _ False = stop -- failed
|
||||||
|
|
|
@ -44,7 +44,7 @@ fieldTransfer :: Direction -> Key -> (MeterUpdate -> Annex Bool) -> CommandStart
|
||||||
fieldTransfer direction key a = do
|
fieldTransfer direction key a = do
|
||||||
afile <- Fields.getField Fields.associatedFile
|
afile <- Fields.getField Fields.associatedFile
|
||||||
ok <- maybe (a $ const noop)
|
ok <- maybe (a $ const noop)
|
||||||
(\u -> runner (Transfer direction (toUUID u) key) afile noRetry a)
|
(\u -> runner (Transfer direction (toUUID u) key) afile noRetry noObserver a)
|
||||||
=<< Fields.getField Fields.remoteUUID
|
=<< Fields.getField Fields.remoteUUID
|
||||||
liftIO $ exitBool ok
|
liftIO $ exitBool ok
|
||||||
where
|
where
|
||||||
|
|
|
@ -42,7 +42,7 @@ start to from file key =
|
||||||
|
|
||||||
toPerform :: Remote -> Key -> AssociatedFile -> CommandPerform
|
toPerform :: Remote -> Key -> AssociatedFile -> CommandPerform
|
||||||
toPerform remote key file = go Upload file $
|
toPerform remote key file = go Upload file $
|
||||||
upload (uuid remote) key file forwardRetry $ \p -> do
|
upload (uuid remote) key file forwardRetry noObserver $ \p -> do
|
||||||
ok <- Remote.storeKey remote key file p
|
ok <- Remote.storeKey remote key file p
|
||||||
when ok $
|
when ok $
|
||||||
Remote.logStatus remote key InfoPresent
|
Remote.logStatus remote key InfoPresent
|
||||||
|
@ -50,7 +50,7 @@ toPerform remote key file = go Upload file $
|
||||||
|
|
||||||
fromPerform :: Remote -> Key -> AssociatedFile -> CommandPerform
|
fromPerform :: Remote -> Key -> AssociatedFile -> CommandPerform
|
||||||
fromPerform remote key file = go Upload file $
|
fromPerform remote key file = go Upload file $
|
||||||
download (uuid remote) key file forwardRetry $ \p ->
|
download (uuid remote) key file forwardRetry noObserver $ \p ->
|
||||||
getViaTmp key $ \t -> Remote.retrieveKeyFile remote key file t p
|
getViaTmp key $ \t -> Remote.retrieveKeyFile remote key file t p
|
||||||
|
|
||||||
go :: Direction -> AssociatedFile -> (NotifyWitness -> Annex Bool) -> CommandPerform
|
go :: Direction -> AssociatedFile -> (NotifyWitness -> Annex Bool) -> CommandPerform
|
||||||
|
|
|
@ -36,14 +36,17 @@ start = do
|
||||||
where
|
where
|
||||||
runner (TransferRequest direction remote key file)
|
runner (TransferRequest direction remote key file)
|
||||||
| direction == Upload = notifyTransfer direction file $
|
| direction == Upload = notifyTransfer direction file $
|
||||||
upload (Remote.uuid remote) key file forwardRetry $ \p -> do
|
upload (Remote.uuid remote) key file forwardRetry observer $ \p -> do
|
||||||
ok <- Remote.storeKey remote key file p
|
ok <- Remote.storeKey remote key file p
|
||||||
when ok $
|
when ok $
|
||||||
Remote.logStatus remote key InfoPresent
|
Remote.logStatus remote key InfoPresent
|
||||||
return ok
|
return ok
|
||||||
| otherwise = notifyTransfer direction file $
|
| otherwise = notifyTransfer direction file $
|
||||||
download (Remote.uuid remote) key file forwardRetry $ \p ->
|
download (Remote.uuid remote) key file forwardRetry observer $ \p ->
|
||||||
getViaTmp key $ \t -> Remote.retrieveKeyFile remote key file t p
|
getViaTmp key $ \t -> Remote.retrieveKeyFile remote key file t p
|
||||||
|
|
||||||
|
observer False t info = recordFailedTransfer t info
|
||||||
|
observer True _ _ = noop
|
||||||
|
|
||||||
runRequests
|
runRequests
|
||||||
:: Handle
|
:: Handle
|
||||||
|
|
|
@ -386,7 +386,7 @@ copyFromRemote' r key file dest meterupdate
|
||||||
let go = copier
|
let go = copier
|
||||||
#endif
|
#endif
|
||||||
runTransfer (Transfer Download u key)
|
runTransfer (Transfer Download u key)
|
||||||
file noRetry go
|
file noRetry noObserver go
|
||||||
<&&> checksuccess
|
<&&> checksuccess
|
||||||
| Git.repoIsSsh (repo r) = feedprogressback $ \feeder -> do
|
| Git.repoIsSsh (repo r) = feedprogressback $ \feeder -> do
|
||||||
direct <- isDirect
|
direct <- isDirect
|
||||||
|
@ -502,7 +502,7 @@ copyToRemote' r key file p
|
||||||
( return True
|
( return True
|
||||||
, do
|
, do
|
||||||
ensureInitialized
|
ensureInitialized
|
||||||
runTransfer (Transfer Download u key) file noRetry $ const $
|
runTransfer (Transfer Download u key) file noRetry noObserver $ const $
|
||||||
Annex.Content.saveState True `after`
|
Annex.Content.saveState True `after`
|
||||||
Annex.Content.getViaTmpChecked (liftIO checksuccessio) key
|
Annex.Content.getViaTmpChecked (liftIO checksuccessio) key
|
||||||
(\d -> rsyncOrCopyFile params object d p)
|
(\d -> rsyncOrCopyFile params object d p)
|
||||||
|
|
2
debian/changelog
vendored
2
debian/changelog
vendored
|
@ -12,6 +12,8 @@ git-annex (5.20150508.2) UNRELEASED; urgency=medium
|
||||||
* --quiet now makes progress output by rsync, wget, etc be quiet too.
|
* --quiet now makes progress output by rsync, wget, etc be quiet too.
|
||||||
* Take space that will be used by running downloads into account when
|
* Take space that will be used by running downloads into account when
|
||||||
checking annex.diskreserve.
|
checking annex.diskreserve.
|
||||||
|
* Avoid accumulating transfer failure log files unless the assistant is
|
||||||
|
being used.
|
||||||
|
|
||||||
-- Joey Hess <id@joeyh.name> Mon, 11 May 2015 12:45:06 -0400
|
-- Joey Hess <id@joeyh.name> Mon, 11 May 2015 12:45:06 -0400
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue