annex.addunlocked

* add, addurl, import, importfeed: When in a v6 repository on a crippled
  filesystem, add files unlocked.
* annex.addunlocked: New configuration setting, makes files always be
  added unlocked. (v6 only)
This commit is contained in:
Joey Hess 2016-02-16 14:43:43 -04:00
parent adc27f081a
commit 15148ee9eb
Failed to extract signature
8 changed files with 116 additions and 39 deletions

View file

@ -12,12 +12,10 @@ import Annex.Ingest
import Logs.Location
import Annex.Content
import Annex.Content.Direct
import Annex.Link
import qualified Annex
import qualified Annex.Queue
import qualified Database.Keys
import Config
import Utility.InodeCache
import Annex.FileMatcher
import Annex.Version
@ -99,48 +97,42 @@ start file = ifAnnexed file addpresent add
( do
ms <- liftIO $ catchMaybeIO $ getSymbolicLinkStatus file
case ms of
Just s | isSymbolicLink s -> fixup key
Just s | isSymbolicLink s -> fixuplink key
_ -> ifM (sameInodeCache file =<< Database.Keys.getInodeCaches key)
( stop, add )
, ifM isDirect
( do
ms <- liftIO $ catchMaybeIO $ getSymbolicLinkStatus file
case ms of
Just s | isSymbolicLink s -> fixup key
Just s | isSymbolicLink s -> fixuplink key
_ -> ifM (goodContent key file)
( stop , add )
, fixup key
, fixuplink key
)
)
fixup key = do
fixuplink key = do
-- the annexed symlink is present but not yet added to git
showStart "add" file
liftIO $ removeFile file
whenM isDirect $
void $ addAssociatedFile key file
next $ next $ cleanup file key Nothing =<< inAnnex key
next $ next $ do
addLink file key Nothing
cleanup key =<< inAnnex key
perform :: FilePath -> CommandPerform
perform file = do
lockingfile <- not <$> isDirect
lockingfile <- not <$> addUnlocked
let cfg = LockDownConfig
{ lockingFile = lockingfile
, hardlinkFileTmp = True
}
lockDown cfg file >>= ingest >>= go
lockDown cfg file >>= ingestAdd >>= finish
where
go (Just key, cache) = next $ cleanup file key cache True
go (Nothing, _) = stop
finish (Just key) = next $ cleanup key True
finish Nothing = stop
cleanup :: FilePath -> Key -> Maybe InodeCache -> Bool -> CommandCleanup
cleanup file key mcache hascontent = do
cleanup :: Key -> Bool -> CommandCleanup
cleanup key hascontent = do
maybeShowJSON [("key", key2file key)]
ifM (isDirect <&&> pure hascontent)
( do
l <- calcRepo $ gitAnnexLink file key
stageSymlink file =<< hashSymlink l
, addLink file key mcache
)
when hascontent $
logStatus key InfoPresent
return True