addurl, importfeed: Improve behavior when file being added is gitignored.
This commit is contained in:
parent
f7ac2bc868
commit
c910004d50
3 changed files with 23 additions and 11 deletions
|
@ -32,6 +32,7 @@ git-annex (6.20160908) UNRELEASED; urgency=medium
|
||||||
* Also, running sync in an adjusted branch did not correctly sync
|
* Also, running sync in an adjusted branch did not correctly sync
|
||||||
changes back to the parent branch when it had a slash in its name.
|
changes back to the parent branch when it had a slash in its name.
|
||||||
This bug has been fixed.
|
This bug has been fixed.
|
||||||
|
* addurl, importfeed: Improve behavior when file being added is gitignored.
|
||||||
|
|
||||||
-- Joey Hess <id@joeyh.name> Thu, 08 Sep 2016 12:48:55 -0400
|
-- Joey Hess <id@joeyh.name> Thu, 08 Sep 2016 12:48:55 -0400
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@ import qualified Types.Remote as Remote
|
||||||
import qualified Command.Add
|
import qualified Command.Add
|
||||||
import Annex.Content
|
import Annex.Content
|
||||||
import Annex.Ingest
|
import Annex.Ingest
|
||||||
|
import Annex.CheckIgnore
|
||||||
import Annex.UUID
|
import Annex.UUID
|
||||||
import Logs.Web
|
import Logs.Web
|
||||||
import Types.KeySource
|
import Types.KeySource
|
||||||
|
@ -157,7 +158,7 @@ performRemote r relaxed uri file sz = ifAnnexed file adduri geturi
|
||||||
geturi = next $ isJust <$> downloadRemoteFile r relaxed uri file sz
|
geturi = next $ isJust <$> downloadRemoteFile r relaxed uri file sz
|
||||||
|
|
||||||
downloadRemoteFile :: Remote -> Bool -> URLString -> FilePath -> Maybe Integer -> Annex (Maybe Key)
|
downloadRemoteFile :: Remote -> Bool -> URLString -> FilePath -> Maybe Integer -> Annex (Maybe Key)
|
||||||
downloadRemoteFile r relaxed uri file sz = do
|
downloadRemoteFile r relaxed uri file sz = checkCanAdd file $ do
|
||||||
let urlkey = Backend.URL.fromUrl uri sz
|
let urlkey = Backend.URL.fromUrl uri sz
|
||||||
liftIO $ createDirectoryIfMissing True (parentDir file)
|
liftIO $ createDirectoryIfMissing True (parentDir file)
|
||||||
ifM (Annex.getState Annex.fast <||> pure relaxed)
|
ifM (Annex.getState Annex.fast <||> pure relaxed)
|
||||||
|
@ -236,7 +237,7 @@ performQuvi relaxed pageurl videourl file = ifAnnexed file addurl geturl
|
||||||
geturl = next $ isJust <$> addUrlFileQuvi relaxed quviurl videourl file
|
geturl = next $ isJust <$> addUrlFileQuvi relaxed quviurl videourl file
|
||||||
|
|
||||||
addUrlFileQuvi :: Bool -> URLString -> URLString -> FilePath -> Annex (Maybe Key)
|
addUrlFileQuvi :: Bool -> URLString -> URLString -> FilePath -> Annex (Maybe Key)
|
||||||
addUrlFileQuvi relaxed quviurl videourl file = stopUnless (doesNotExist file) $ do
|
addUrlFileQuvi relaxed quviurl videourl file = checkCanAdd file $ do
|
||||||
let key = Backend.URL.fromUrl quviurl Nothing
|
let key = Backend.URL.fromUrl quviurl Nothing
|
||||||
ifM (pure relaxed <||> Annex.getState Annex.fast)
|
ifM (pure relaxed <||> Annex.getState Annex.fast)
|
||||||
( do
|
( do
|
||||||
|
@ -285,21 +286,13 @@ addUrlChecked relaxed url u checkexistssize key
|
||||||
)
|
)
|
||||||
|
|
||||||
addUrlFile :: Bool -> URLString -> Url.UrlInfo -> FilePath -> Annex (Maybe Key)
|
addUrlFile :: Bool -> URLString -> Url.UrlInfo -> FilePath -> Annex (Maybe Key)
|
||||||
addUrlFile relaxed url urlinfo file = stopUnless (doesNotExist file) $ do
|
addUrlFile relaxed url urlinfo file = checkCanAdd file $ do
|
||||||
liftIO $ createDirectoryIfMissing True (parentDir file)
|
liftIO $ createDirectoryIfMissing True (parentDir file)
|
||||||
ifM (Annex.getState Annex.fast <||> pure relaxed)
|
ifM (Annex.getState Annex.fast <||> pure relaxed)
|
||||||
( nodownload url urlinfo file
|
( nodownload url urlinfo file
|
||||||
, downloadWeb url urlinfo file
|
, downloadWeb url urlinfo file
|
||||||
)
|
)
|
||||||
|
|
||||||
doesNotExist :: FilePath -> Annex Bool
|
|
||||||
doesNotExist file = go =<< liftIO (catchMaybeIO $ getSymbolicLinkStatus file)
|
|
||||||
where
|
|
||||||
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 :: URLString -> Url.UrlInfo -> FilePath -> Annex (Maybe Key)
|
||||||
downloadWeb url urlinfo file = do
|
downloadWeb url urlinfo file = do
|
||||||
let dummykey = addSizeUrlKey urlinfo $ Backend.URL.fromUrl url Nothing
|
let dummykey = addSizeUrlKey urlinfo $ Backend.URL.fromUrl url Nothing
|
||||||
|
@ -400,3 +393,16 @@ adjustFile o = addprefix . addsuffix
|
||||||
where
|
where
|
||||||
addprefix f = maybe f (++ f) (prefixOption o)
|
addprefix f = maybe f (++ f) (prefixOption o)
|
||||||
addsuffix f = maybe f (f ++) (suffixOption o)
|
addsuffix f = maybe f (f ++) (suffixOption o)
|
||||||
|
|
||||||
|
checkCanAdd :: FilePath -> Annex (Maybe a) -> Annex (Maybe a)
|
||||||
|
checkCanAdd file a = ifM (isJust <$> (liftIO $ catchMaybeIO $ getSymbolicLinkStatus file))
|
||||||
|
( do
|
||||||
|
warning $ file ++ " already exists and is not annexed; not overwriting"
|
||||||
|
return Nothing
|
||||||
|
, ifM ((not <$> Annex.getState Annex.force) <&&> checkIgnored file)
|
||||||
|
( do
|
||||||
|
warning $ "not adding " ++ file ++ " which is .gitignored (use --force to override)"
|
||||||
|
return Nothing
|
||||||
|
, a
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
|
@ -29,3 +29,8 @@ git-annex: user error (xargs ["-0","git","--git-dir=.git","--work-tree=.","--lit
|
||||||
"""]]
|
"""]]
|
||||||
|
|
||||||
[[!meta author=yoh]]
|
[[!meta author=yoh]]
|
||||||
|
|
||||||
|
> And it leaves the unstaged symlink behind too.
|
||||||
|
>
|
||||||
|
> [[fixed|done]] to check ignore status before creating the file.
|
||||||
|
> --[[Joey]]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue