0896038ba7
Added annex.adjustedbranchrefresh git config to update adjusted branches set up by git-annex adjust --unlock-present/--hide-missing. Note, in a few cases, I was not able to make the adjusted branch be updated in calls to moveAnnex, because information about what file corresponds to a key is not available. They are: * If two files point to one file, then eg, `git annex get foo` will update the branch to unlock foo, but will not unlock bar, because it does not know about it. Might be fixable by making `git annex get bar` do something besides skipping bar? * git-annex-shell recvkey likewise (so sends over ssh from old versions of git-annex) * git-annex setkey * git-annex transferkey if the user does not use --file * git-annex multicast sends keys with no associated file info Doing a single full refresh at the end, after any incremental refresh, will deal with those edge cases.
51 lines
1.4 KiB
Haskell
51 lines
1.4 KiB
Haskell
{- git-annex command
|
|
-
|
|
- Copyright 2010, 2015 Joey Hess <joey@kitenet.net>
|
|
-
|
|
- Licensed under the GNU AGPL version 3 or higher.
|
|
-}
|
|
|
|
module Command.SetKey where
|
|
|
|
import Command
|
|
import Logs.Location
|
|
import Annex.Content
|
|
|
|
cmd :: Command
|
|
cmd = command "setkey" SectionPlumbing "sets annexed content for a key"
|
|
(paramPair paramKey paramPath)
|
|
(withParams seek)
|
|
|
|
seek :: CmdParams -> CommandSeek
|
|
seek = withWords (commandAction . start)
|
|
|
|
start :: [String] -> CommandStart
|
|
start ps@(keyname:file:[]) = starting "setkey" ai si $
|
|
perform (toRawFilePath file) (keyOpt keyname)
|
|
where
|
|
ai = ActionItemOther (Just file)
|
|
si = SeekInput ps
|
|
start _ = giveup "specify a key and a content file"
|
|
|
|
keyOpt :: String -> Key
|
|
keyOpt = fromMaybe (giveup "bad key") . deserializeKey
|
|
|
|
perform :: RawFilePath -> Key -> CommandPerform
|
|
perform file key = do
|
|
-- the file might be on a different filesystem, so moveFile is used
|
|
-- rather than simply calling moveAnnex; disk space is also
|
|
-- checked this way.
|
|
ok <- getViaTmp RetrievalAllKeysSecure DefaultVerify key (AssociatedFile Nothing) $ \dest -> unVerified $
|
|
if dest /= file
|
|
then liftIO $ catchBoolIO $ do
|
|
moveFile (fromRawFilePath file) (fromRawFilePath dest)
|
|
return True
|
|
else return True
|
|
if ok
|
|
then next $ cleanup key
|
|
else error "mv failed!"
|
|
|
|
cleanup :: Key -> CommandCleanup
|
|
cleanup key = do
|
|
logStatus key InfoPresent
|
|
return True
|