reorg
This commit is contained in:
parent
0ef282a116
commit
f7cdc40f7b
14 changed files with 91 additions and 77 deletions
|
@ -9,7 +9,7 @@ module Annex.Drop where
|
||||||
|
|
||||||
import Common.Annex
|
import Common.Annex
|
||||||
import Logs.Trust
|
import Logs.Trust
|
||||||
import Logs.NumCopies
|
import Config.NumCopies
|
||||||
import Types.Remote (uuid)
|
import Types.Remote (uuid)
|
||||||
import qualified Remote
|
import qualified Remote
|
||||||
import qualified Command.Drop
|
import qualified Command.Drop
|
||||||
|
|
|
@ -17,11 +17,11 @@ import qualified Annex
|
||||||
import qualified Git
|
import qualified Git
|
||||||
import Config
|
import Config
|
||||||
import Config.Files
|
import Config.Files
|
||||||
|
import Config.NumCopies
|
||||||
import Utility.DataUnits
|
import Utility.DataUnits
|
||||||
import Git.Config
|
import Git.Config
|
||||||
import Types.Distribution
|
import Types.Distribution
|
||||||
import qualified Build.SysConfig
|
import qualified Build.SysConfig
|
||||||
import Logs.NumCopies
|
|
||||||
|
|
||||||
import qualified Data.Text as T
|
import qualified Data.Text as T
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ import GitAnnex.Options
|
||||||
import qualified Command.Move
|
import qualified Command.Move
|
||||||
import qualified Remote
|
import qualified Remote
|
||||||
import Annex.Wanted
|
import Annex.Wanted
|
||||||
import Logs.NumCopies
|
import Config.NumCopies
|
||||||
|
|
||||||
def :: [Command]
|
def :: [Command]
|
||||||
def = [withOptions Command.Move.moveOptions $ command "copy" paramPaths seek
|
def = [withOptions Command.Move.moveOptions $ command "copy" paramPaths seek
|
||||||
|
|
|
@ -14,7 +14,7 @@ import qualified Annex
|
||||||
import Annex.UUID
|
import Annex.UUID
|
||||||
import Logs.Location
|
import Logs.Location
|
||||||
import Logs.Trust
|
import Logs.Trust
|
||||||
import Logs.NumCopies
|
import Config.NumCopies
|
||||||
import Annex.Content
|
import Annex.Content
|
||||||
import qualified Option
|
import qualified Option
|
||||||
import Annex.Wanted
|
import Annex.Wanted
|
||||||
|
|
|
@ -15,7 +15,7 @@ import qualified Remote
|
||||||
import qualified Git
|
import qualified Git
|
||||||
import qualified Option
|
import qualified Option
|
||||||
import Command.Unused (withUnusedMaps, UnusedMaps(..), startUnused)
|
import Command.Unused (withUnusedMaps, UnusedMaps(..), startUnused)
|
||||||
import Logs.NumCopies
|
import Config.NumCopies
|
||||||
|
|
||||||
def :: [Command]
|
def :: [Command]
|
||||||
def = [withOptions [Command.Drop.fromOption] $
|
def = [withOptions [Command.Drop.fromOption] $
|
||||||
|
|
|
@ -25,7 +25,7 @@ import Annex.Perms
|
||||||
import Annex.Link
|
import Annex.Link
|
||||||
import Logs.Location
|
import Logs.Location
|
||||||
import Logs.Trust
|
import Logs.Trust
|
||||||
import Logs.NumCopies
|
import Config.NumCopies
|
||||||
import Annex.UUID
|
import Annex.UUID
|
||||||
import Utility.DataUnits
|
import Utility.DataUnits
|
||||||
import Utility.FileMode
|
import Utility.FileMode
|
||||||
|
|
|
@ -12,7 +12,7 @@ import Command
|
||||||
import qualified Remote
|
import qualified Remote
|
||||||
import Annex.Content
|
import Annex.Content
|
||||||
import Logs.Transfer
|
import Logs.Transfer
|
||||||
import Logs.NumCopies
|
import Config.NumCopies
|
||||||
import Annex.Wanted
|
import Annex.Wanted
|
||||||
import GitAnnex.Options
|
import GitAnnex.Options
|
||||||
import qualified Command.Move
|
import qualified Command.Move
|
||||||
|
|
|
@ -29,7 +29,7 @@ import Annex.Content
|
||||||
import Types.Key
|
import Types.Key
|
||||||
import Logs.UUID
|
import Logs.UUID
|
||||||
import Logs.Trust
|
import Logs.Trust
|
||||||
import Logs.NumCopies
|
import Config.NumCopies
|
||||||
import Remote
|
import Remote
|
||||||
import Config
|
import Config
|
||||||
import Utility.Percentage
|
import Utility.Percentage
|
||||||
|
|
|
@ -16,7 +16,7 @@ import qualified Command.Get
|
||||||
import qualified Remote
|
import qualified Remote
|
||||||
import Annex.Content
|
import Annex.Content
|
||||||
import qualified Annex
|
import qualified Annex
|
||||||
import Logs.NumCopies
|
import Config.NumCopies
|
||||||
|
|
||||||
def :: [Command]
|
def :: [Command]
|
||||||
def = [withOptions (fromToOptions ++ keyOptions) $
|
def = [withOptions (fromToOptions ++ keyOptions) $
|
||||||
|
|
|
@ -10,7 +10,7 @@ module Command.NumCopies where
|
||||||
import Common.Annex
|
import Common.Annex
|
||||||
import qualified Annex
|
import qualified Annex
|
||||||
import Command
|
import Command
|
||||||
import Logs.NumCopies
|
import Config.NumCopies
|
||||||
import Types.Messages
|
import Types.Messages
|
||||||
|
|
||||||
def :: [Command]
|
def :: [Command]
|
||||||
|
|
80
Config/NumCopies.hs
Normal file
80
Config/NumCopies.hs
Normal file
|
@ -0,0 +1,80 @@
|
||||||
|
{- git-annex numcopies configuration
|
||||||
|
-
|
||||||
|
- Copyright 2014 Joey Hess <joey@kitenet.net>
|
||||||
|
-
|
||||||
|
- Licensed under the GNU GPL version 3 or higher.
|
||||||
|
-}
|
||||||
|
|
||||||
|
module Config.NumCopies (
|
||||||
|
module Types.NumCopies,
|
||||||
|
module Logs.NumCopies,
|
||||||
|
getFileNumCopies,
|
||||||
|
getGlobalFileNumCopies,
|
||||||
|
getNumCopies,
|
||||||
|
numCopiesCheck,
|
||||||
|
deprecatedNumCopies,
|
||||||
|
defaultNumCopies
|
||||||
|
) where
|
||||||
|
|
||||||
|
import Common.Annex
|
||||||
|
import qualified Annex
|
||||||
|
import Types.NumCopies
|
||||||
|
import Logs.NumCopies
|
||||||
|
import Logs.Trust
|
||||||
|
import Annex.CheckAttr
|
||||||
|
import qualified Remote
|
||||||
|
|
||||||
|
defaultNumCopies :: NumCopies
|
||||||
|
defaultNumCopies = NumCopies 1
|
||||||
|
|
||||||
|
fromSources :: [Annex (Maybe NumCopies)] -> Annex NumCopies
|
||||||
|
fromSources = fromMaybe defaultNumCopies <$$> getM id
|
||||||
|
|
||||||
|
{- The git config annex.numcopies is deprecated. -}
|
||||||
|
deprecatedNumCopies :: Annex (Maybe NumCopies)
|
||||||
|
deprecatedNumCopies = annexNumCopies <$> Annex.getGitConfig
|
||||||
|
|
||||||
|
{- Value forced on the command line by --numcopies. -}
|
||||||
|
getForcedNumCopies :: Annex (Maybe NumCopies)
|
||||||
|
getForcedNumCopies = Annex.getState Annex.forcenumcopies
|
||||||
|
|
||||||
|
{- Numcopies value from any of the non-.gitattributes configuration
|
||||||
|
- sources. -}
|
||||||
|
getNumCopies :: Annex NumCopies
|
||||||
|
getNumCopies = fromSources
|
||||||
|
[ getForcedNumCopies
|
||||||
|
, getGlobalNumCopies
|
||||||
|
, deprecatedNumCopies
|
||||||
|
]
|
||||||
|
|
||||||
|
{- Numcopies value for a file, from any configuration source, including the
|
||||||
|
- deprecated git config. -}
|
||||||
|
getFileNumCopies :: FilePath -> Annex NumCopies
|
||||||
|
getFileNumCopies f = fromSources
|
||||||
|
[ getForcedNumCopies
|
||||||
|
, getFileNumCopies' f
|
||||||
|
, deprecatedNumCopies
|
||||||
|
]
|
||||||
|
|
||||||
|
{- This is the globally visible numcopies value for a file. So it does
|
||||||
|
- not include local configuration in the git config or command line
|
||||||
|
- options. -}
|
||||||
|
getGlobalFileNumCopies :: FilePath -> Annex NumCopies
|
||||||
|
getGlobalFileNumCopies f = fromSources
|
||||||
|
[ getFileNumCopies' f
|
||||||
|
]
|
||||||
|
|
||||||
|
getFileNumCopies' :: FilePath -> Annex (Maybe NumCopies)
|
||||||
|
getFileNumCopies' file = maybe getGlobalNumCopies (return . Just) =<< getattr
|
||||||
|
where
|
||||||
|
getattr = (NumCopies <$$> readish)
|
||||||
|
<$> checkAttr "annex.numcopies" file
|
||||||
|
|
||||||
|
{- Checks if numcopies are satisfied for a file by running a comparison
|
||||||
|
- between the number of (not untrusted) copies that are
|
||||||
|
- belived to exist, and the configured value. -}
|
||||||
|
numCopiesCheck :: FilePath -> Key -> (Int -> Int -> v) -> Annex v
|
||||||
|
numCopiesCheck file key vs = do
|
||||||
|
NumCopies needed <- getFileNumCopies file
|
||||||
|
have <- trustExclude UnTrusted =<< Remote.keyLocations key
|
||||||
|
return $ length have `vs` needed
|
2
Limit.hs
2
Limit.hs
|
@ -23,7 +23,7 @@ import qualified Backend
|
||||||
import Annex.Content
|
import Annex.Content
|
||||||
import Annex.UUID
|
import Annex.UUID
|
||||||
import Logs.Trust
|
import Logs.Trust
|
||||||
import Logs.NumCopies
|
import Config.NumCopies
|
||||||
import Types.TrustLevel
|
import Types.TrustLevel
|
||||||
import Types.Key
|
import Types.Key
|
||||||
import Types.Group
|
import Types.Group
|
||||||
|
|
|
@ -8,16 +8,9 @@
|
||||||
{-# OPTIONS_GHC -fno-warn-orphans #-}
|
{-# OPTIONS_GHC -fno-warn-orphans #-}
|
||||||
|
|
||||||
module Logs.NumCopies (
|
module Logs.NumCopies (
|
||||||
module Types.NumCopies,
|
|
||||||
setGlobalNumCopies,
|
setGlobalNumCopies,
|
||||||
getGlobalNumCopies,
|
getGlobalNumCopies,
|
||||||
globalNumCopiesLoad,
|
globalNumCopiesLoad,
|
||||||
getFileNumCopies,
|
|
||||||
getGlobalFileNumCopies,
|
|
||||||
getNumCopies,
|
|
||||||
numCopiesCheck,
|
|
||||||
deprecatedNumCopies,
|
|
||||||
defaultNumCopies
|
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import Common.Annex
|
import Common.Annex
|
||||||
|
@ -25,9 +18,6 @@ import qualified Annex
|
||||||
import Types.NumCopies
|
import Types.NumCopies
|
||||||
import Logs
|
import Logs
|
||||||
import Logs.SingleValue
|
import Logs.SingleValue
|
||||||
import Logs.Trust
|
|
||||||
import Annex.CheckAttr
|
|
||||||
import qualified Remote
|
|
||||||
|
|
||||||
instance SingleValueSerializable NumCopies where
|
instance SingleValueSerializable NumCopies where
|
||||||
serialize (NumCopies n) = show n
|
serialize (NumCopies n) = show n
|
||||||
|
@ -46,58 +36,3 @@ globalNumCopiesLoad = do
|
||||||
v <- getLog numcopiesLog
|
v <- getLog numcopiesLog
|
||||||
Annex.changeState $ \s -> s { Annex.globalnumcopies = v }
|
Annex.changeState $ \s -> s { Annex.globalnumcopies = v }
|
||||||
return v
|
return v
|
||||||
|
|
||||||
defaultNumCopies :: NumCopies
|
|
||||||
defaultNumCopies = NumCopies 1
|
|
||||||
|
|
||||||
fromSources :: [Annex (Maybe NumCopies)] -> Annex NumCopies
|
|
||||||
fromSources = fromMaybe defaultNumCopies <$$> getM id
|
|
||||||
|
|
||||||
{- The git config annex.numcopies is deprecated. -}
|
|
||||||
deprecatedNumCopies :: Annex (Maybe NumCopies)
|
|
||||||
deprecatedNumCopies = annexNumCopies <$> Annex.getGitConfig
|
|
||||||
|
|
||||||
{- Value forced on the command line by --numcopies. -}
|
|
||||||
getForcedNumCopies :: Annex (Maybe NumCopies)
|
|
||||||
getForcedNumCopies = Annex.getState Annex.forcenumcopies
|
|
||||||
|
|
||||||
{- Numcopies value from any of the non-.gitattributes configuration
|
|
||||||
- sources. -}
|
|
||||||
getNumCopies :: Annex NumCopies
|
|
||||||
getNumCopies = fromSources
|
|
||||||
[ getForcedNumCopies
|
|
||||||
, getGlobalNumCopies
|
|
||||||
, deprecatedNumCopies
|
|
||||||
]
|
|
||||||
|
|
||||||
{- Numcopies value for a file, from any configuration source, including the
|
|
||||||
- deprecated git config. -}
|
|
||||||
getFileNumCopies :: FilePath -> Annex NumCopies
|
|
||||||
getFileNumCopies f = fromSources
|
|
||||||
[ getForcedNumCopies
|
|
||||||
, getFileNumCopies' f
|
|
||||||
, deprecatedNumCopies
|
|
||||||
]
|
|
||||||
|
|
||||||
{- This is the globally visible numcopies value for a file. So it does
|
|
||||||
- not include local configuration in the git config or command line
|
|
||||||
- options. -}
|
|
||||||
getGlobalFileNumCopies :: FilePath -> Annex NumCopies
|
|
||||||
getGlobalFileNumCopies f = fromSources
|
|
||||||
[ getFileNumCopies' f
|
|
||||||
]
|
|
||||||
|
|
||||||
getFileNumCopies' :: FilePath -> Annex (Maybe NumCopies)
|
|
||||||
getFileNumCopies' file = maybe getGlobalNumCopies (return . Just) =<< getattr
|
|
||||||
where
|
|
||||||
getattr = (NumCopies <$$> readish)
|
|
||||||
<$> checkAttr "annex.numcopies" file
|
|
||||||
|
|
||||||
{- Checks if numcopies are satisfied for a file by running a comparison
|
|
||||||
- between the number of (not untrusted) copies that are
|
|
||||||
- belived to exist, and the configured value. -}
|
|
||||||
numCopiesCheck :: FilePath -> Key -> (Int -> Int -> v) -> Annex v
|
|
||||||
numCopiesCheck file key vs = do
|
|
||||||
NumCopies needed <- getFileNumCopies file
|
|
||||||
have <- trustExclude UnTrusted =<< Remote.keyLocations key
|
|
||||||
return $ length have `vs` needed
|
|
||||||
|
|
|
@ -79,7 +79,6 @@ extractGitConfig r = GitConfig
|
||||||
, gcryptId = getmaybe "core.gcrypt-id"
|
, gcryptId = getmaybe "core.gcrypt-id"
|
||||||
}
|
}
|
||||||
where
|
where
|
||||||
get k def = fromMaybe def $ getmayberead k
|
|
||||||
getbool k def = fromMaybe def $ getmaybebool k
|
getbool k def = fromMaybe def $ getmaybebool k
|
||||||
getmaybebool k = Git.Config.isTrue =<< getmaybe k
|
getmaybebool k = Git.Config.isTrue =<< getmaybe k
|
||||||
getmayberead k = readish =<< getmaybe k
|
getmayberead k = readish =<< getmaybe k
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue