fix checkPresent error handling for non-present local git repos
guardUsable r (error "foo") *returned* an error, rather than throwing it
This commit is contained in:
parent
1dd3232e8e
commit
4f1ba9a23d
3 changed files with 18 additions and 17 deletions
|
@ -306,7 +306,7 @@ setGcryptEncryption c remotename = do
|
||||||
store :: Remote -> Remote.Rsync.RsyncOpts -> Storer
|
store :: Remote -> Remote.Rsync.RsyncOpts -> Storer
|
||||||
store r rsyncopts
|
store r rsyncopts
|
||||||
| not $ Git.repoIsUrl (repo r) =
|
| not $ Git.repoIsUrl (repo r) =
|
||||||
byteStorer $ \k b p -> guardUsable (repo r) False $ liftIO $ do
|
byteStorer $ \k b p -> guardUsable (repo r) (return False) $ liftIO $ do
|
||||||
let tmpdir = Git.repoLocation (repo r) </> "tmp" </> keyFile k
|
let tmpdir = Git.repoLocation (repo r) </> "tmp" </> keyFile k
|
||||||
void $ tryIO $ createDirectoryIfMissing True tmpdir
|
void $ tryIO $ createDirectoryIfMissing True tmpdir
|
||||||
let tmpf = tmpdir </> keyFile k
|
let tmpf = tmpdir </> keyFile k
|
||||||
|
@ -323,7 +323,7 @@ store r rsyncopts
|
||||||
retrieve :: Remote -> Remote.Rsync.RsyncOpts -> Retriever
|
retrieve :: Remote -> Remote.Rsync.RsyncOpts -> Retriever
|
||||||
retrieve r rsyncopts
|
retrieve r rsyncopts
|
||||||
| not $ Git.repoIsUrl (repo r) = byteRetriever $ \k sink ->
|
| not $ Git.repoIsUrl (repo r) = byteRetriever $ \k sink ->
|
||||||
guardUsable (repo r) False $
|
guardUsable (repo r) (return False) $
|
||||||
sink =<< liftIO (L.readFile $ gCryptLocation r k)
|
sink =<< liftIO (L.readFile $ gCryptLocation r k)
|
||||||
| Git.repoIsSsh (repo r) = if isShell r
|
| Git.repoIsSsh (repo r) = if isShell r
|
||||||
then fileRetriever $ \f k p ->
|
then fileRetriever $ \f k p ->
|
||||||
|
@ -335,7 +335,7 @@ retrieve r rsyncopts
|
||||||
|
|
||||||
remove :: Remote -> Remote.Rsync.RsyncOpts -> Remover
|
remove :: Remote -> Remote.Rsync.RsyncOpts -> Remover
|
||||||
remove r rsyncopts k
|
remove r rsyncopts k
|
||||||
| not $ Git.repoIsUrl (repo r) = guardUsable (repo r) False $
|
| not $ Git.repoIsUrl (repo r) = guardUsable (repo r) (return False) $
|
||||||
liftIO $ Remote.Directory.removeDirGeneric (Git.repoLocation (repo r)) (parentDir (gCryptLocation r k))
|
liftIO $ Remote.Directory.removeDirGeneric (Git.repoLocation (repo r)) (parentDir (gCryptLocation r k))
|
||||||
| Git.repoIsSsh (repo r) = shellOrRsync r removeshell removersync
|
| Git.repoIsSsh (repo r) = shellOrRsync r removeshell removersync
|
||||||
| otherwise = unsupportedUrl
|
| otherwise = unsupportedUrl
|
||||||
|
|
|
@ -319,14 +319,15 @@ keyUrls r key = map tourl locs'
|
||||||
dropKey :: Remote -> Key -> Annex Bool
|
dropKey :: Remote -> Key -> Annex Bool
|
||||||
dropKey r key
|
dropKey r key
|
||||||
| not $ Git.repoIsUrl (repo r) =
|
| not $ Git.repoIsUrl (repo r) =
|
||||||
guardUsable (repo r) False $ commitOnCleanup r $ onLocal r $ do
|
guardUsable (repo r) (return False) $
|
||||||
ensureInitialized
|
commitOnCleanup r $ onLocal r $ do
|
||||||
whenM (Annex.Content.inAnnex key) $ do
|
ensureInitialized
|
||||||
Annex.Content.lockContent key $
|
whenM (Annex.Content.inAnnex key) $ do
|
||||||
Annex.Content.removeAnnex key
|
Annex.Content.lockContent key $
|
||||||
logStatus key InfoMissing
|
Annex.Content.removeAnnex key
|
||||||
Annex.Content.saveState True
|
logStatus key InfoMissing
|
||||||
return True
|
Annex.Content.saveState True
|
||||||
|
return True
|
||||||
| Git.repoIsHttp (repo r) = error "dropping from http remote not supported"
|
| Git.repoIsHttp (repo r) = error "dropping from http remote not supported"
|
||||||
| otherwise = commitOnCleanup r $ Ssh.dropKey (repo r) key
|
| otherwise = commitOnCleanup r $ Ssh.dropKey (repo r) key
|
||||||
|
|
||||||
|
@ -335,7 +336,7 @@ copyFromRemote :: Remote -> Key -> AssociatedFile -> FilePath -> MeterUpdate ->
|
||||||
copyFromRemote r key file dest _p = copyFromRemote' r key file dest
|
copyFromRemote r key file dest _p = copyFromRemote' r key file dest
|
||||||
copyFromRemote' :: Remote -> Key -> AssociatedFile -> FilePath -> Annex Bool
|
copyFromRemote' :: Remote -> Key -> AssociatedFile -> FilePath -> Annex Bool
|
||||||
copyFromRemote' r key file dest
|
copyFromRemote' r key file dest
|
||||||
| not $ Git.repoIsUrl (repo r) = guardUsable (repo r) False $ do
|
| not $ Git.repoIsUrl (repo r) = guardUsable (repo r) (return False) $ do
|
||||||
params <- Ssh.rsyncParams r Download
|
params <- Ssh.rsyncParams r Download
|
||||||
u <- getUUID
|
u <- getUUID
|
||||||
-- run copy from perspective of remote
|
-- run copy from perspective of remote
|
||||||
|
@ -409,7 +410,7 @@ copyFromRemote' r key file dest
|
||||||
copyFromRemoteCheap :: Remote -> Key -> FilePath -> Annex Bool
|
copyFromRemoteCheap :: Remote -> Key -> FilePath -> Annex Bool
|
||||||
#ifndef mingw32_HOST_OS
|
#ifndef mingw32_HOST_OS
|
||||||
copyFromRemoteCheap r key file
|
copyFromRemoteCheap r key file
|
||||||
| not $ Git.repoIsUrl (repo r) = guardUsable (repo r) False $ do
|
| not $ Git.repoIsUrl (repo r) = guardUsable (repo r) (return False) $ do
|
||||||
loc <- liftIO $ gitAnnexLocation key (repo r) $
|
loc <- liftIO $ gitAnnexLocation key (repo r) $
|
||||||
fromJust $ remoteGitConfig $ gitconfig r
|
fromJust $ remoteGitConfig $ gitconfig r
|
||||||
liftIO $ catchBoolIO $ createSymbolicLink loc file >> return True
|
liftIO $ catchBoolIO $ createSymbolicLink loc file >> return True
|
||||||
|
@ -427,7 +428,7 @@ copyFromRemoteCheap _ _ _ = return False
|
||||||
copyToRemote :: Remote -> Key -> AssociatedFile -> MeterUpdate -> Annex Bool
|
copyToRemote :: Remote -> Key -> AssociatedFile -> MeterUpdate -> Annex Bool
|
||||||
copyToRemote r key file p
|
copyToRemote r key file p
|
||||||
| not $ Git.repoIsUrl (repo r) =
|
| not $ Git.repoIsUrl (repo r) =
|
||||||
guardUsable (repo r) False $ commitOnCleanup r $
|
guardUsable (repo r) (return False) $ commitOnCleanup r $
|
||||||
copylocal =<< Annex.Content.prepSendAnnex key
|
copylocal =<< Annex.Content.prepSendAnnex key
|
||||||
| Git.repoIsSsh (repo r) = commitOnCleanup r $
|
| Git.repoIsSsh (repo r) = commitOnCleanup r $
|
||||||
Annex.Content.sendAnnex key noop $ \object -> do
|
Annex.Content.sendAnnex key noop $ \object -> do
|
||||||
|
|
|
@ -26,7 +26,7 @@ availabilityCalc r
|
||||||
|
|
||||||
{- Avoids performing an action on a local repository that's not usable.
|
{- Avoids performing an action on a local repository that's not usable.
|
||||||
- Does not check that the repository is still available on disk. -}
|
- Does not check that the repository is still available on disk. -}
|
||||||
guardUsable :: Git.Repo -> a -> Annex a -> Annex a
|
guardUsable :: Git.Repo -> Annex a -> Annex a -> Annex a
|
||||||
guardUsable r onerr a
|
guardUsable r fallback a
|
||||||
| Git.repoIsLocalUnknown r = return onerr
|
| Git.repoIsLocalUnknown r = fallback
|
||||||
| otherwise = a
|
| otherwise = a
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue