aboutsummaryrefslogtreecommitdiff
path: root/Command
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2016-01-15 14:34:33 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2016-01-15 14:34:33 -0400
commit80585840e03b15c6064cae4077aa91df38a543b3 (patch)
treebba86435ee9237f9c94563a472fbb9d1f98fe89d /Command
parent38d5ad051eb93c5b939755587a720a6f6ca7ef4e (diff)
convert existing non-annexed file to non-exception
Diffstat (limited to 'Command')
-rw-r--r--Command/AddUrl.hs16
1 files changed, 8 insertions, 8 deletions
diff --git a/Command/AddUrl.hs b/Command/AddUrl.hs
index 838b8fd4d..d6a4c6143 100644
--- a/Command/AddUrl.hs
+++ b/Command/AddUrl.hs
@@ -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