convert existing non-annexed file to non-exception
This commit is contained in:
parent
b26ce646e4
commit
b9f921248e
3 changed files with 21 additions and 8 deletions
|
@ -258,8 +258,7 @@ performQuvi relaxed pageurl videourl file = ifAnnexed file addurl geturl
|
|||
|
||||
#ifdef WITH_QUVI
|
||||
addUrlFileQuvi :: Bool -> URLString -> URLString -> FilePath -> Annex (Maybe Key)
|
||||
addUrlFileQuvi relaxed quviurl videourl file = do
|
||||
checkDoesNotExist file
|
||||
addUrlFileQuvi relaxed quviurl videourl file = stopUnless (doesNotExist file) $ do
|
||||
let key = Backend.URL.fromUrl quviurl Nothing
|
||||
ifM (pure relaxed <||> Annex.getState Annex.fast)
|
||||
( do
|
||||
|
@ -309,19 +308,20 @@ addUrlChecked relaxed url u checkexistssize key
|
|||
)
|
||||
|
||||
addUrlFile :: Bool -> URLString -> Url.UrlInfo -> FilePath -> Annex (Maybe Key)
|
||||
addUrlFile relaxed url urlinfo file = do
|
||||
checkDoesNotExist file
|
||||
addUrlFile relaxed url urlinfo file = stopUnless (doesNotExist file) $ do
|
||||
liftIO $ createDirectoryIfMissing True (parentDir file)
|
||||
ifM (Annex.getState Annex.fast <||> pure relaxed)
|
||||
( nodownload url urlinfo file
|
||||
, downloadWeb url urlinfo file
|
||||
)
|
||||
|
||||
checkDoesNotExist :: FilePath -> Annex ()
|
||||
checkDoesNotExist file = go =<< liftIO (catchMaybeIO $ getSymbolicLinkStatus file)
|
||||
doesNotExist :: FilePath -> Annex Bool
|
||||
doesNotExist file = go =<< liftIO (catchMaybeIO $ getSymbolicLinkStatus file)
|
||||
where
|
||||
go Nothing = return ()
|
||||
go (Just _) = error $ file ++ " already exists and is not annexed; not overwriting"
|
||||
go Nothing = return True
|
||||
go (Just _) = do
|
||||
warning $ file ++ " already exists and is not annexed; not overwriting"
|
||||
return False
|
||||
|
||||
downloadWeb :: URLString -> Url.UrlInfo -> FilePath -> Annex (Maybe Key)
|
||||
downloadWeb url urlinfo file = do
|
||||
|
|
|
@ -17,3 +17,5 @@ $> echo "http://www.onerussian.com/tmp/banner.png 123" | git annex addurl --batc
|
|||
"""]]
|
||||
|
||||
[[!meta author=yoh]]
|
||||
|
||||
> [[fixed|done]] --[[Joey]]
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
[[!comment format=mdwn
|
||||
username="joey"
|
||||
subject="""comment 2"""
|
||||
date="2016-01-15T18:24:28Z"
|
||||
content="""
|
||||
Dude, you're /dev/nulling stderr, where the error is printed.
|
||||
|
||||
In any case, sure, we can make addurl not throw a fatal error in this
|
||||
particular case. There are of course many other error conditions where it
|
||||
may still throw a fatal error.
|
||||
"""]]
|
Loading…
Add table
Reference in a new issue