where indenting

This commit is contained in:
Joey Hess 2012-11-11 00:51:07 -04:00
parent 6a0756d2fb
commit 2172cc586e
42 changed files with 1193 additions and 1209 deletions

View file

@ -73,8 +73,7 @@ shaN shasize file filesize = do
hClose h hClose h
return output return output
where where
p = (proc command args) p = (proc command args) { std_out = CreatePipe }
{ std_out = CreatePipe }
shaCommand :: SHASize -> Integer -> Either (L.ByteString -> String) String shaCommand :: SHASize -> Integer -> Either (L.ByteString -> String) String
shaCommand shasize filesize shaCommand shasize filesize
@ -87,9 +86,9 @@ shaCommand shasize filesize
where where
use Nothing sha = Left $ showDigest . sha use Nothing sha = Left $ showDigest . sha
use (Just c) sha use (Just c) sha
-- use builtin, but slower sha for small files {- use builtin, but slower sha for small files
-- benchmarking indicates it's faster up to - benchmarking indicates it's faster up to
-- and slightly beyond 50 kb files - and slightly beyond 50 kb files -}
| filesize < 51200 = use Nothing sha | filesize < 51200 = use Nothing sha
| otherwise = Right c | otherwise = Right c

View file

@ -33,9 +33,9 @@ fromUrl url size = stubKey
, keySize = size , keySize = size
} }
where where
-- when it's not too long, use the url as the key name {- when it's not too long, use the url as the key name
-- 256 is the absolute filename max, but use a shorter - 256 is the absolute filename max, but use a shorter
-- length because this is not the entire key filename. - length because this is not the entire key filename. -}
key key
| length url < 128 = url | length url < 128 = url
| otherwise = take 128 url ++ "-" ++ md5s (Str url) | otherwise = take 128 url ++ "-" ++ md5s (Str url)

View file

@ -46,8 +46,7 @@ tests =
shaTestCases :: [(Int, String)] -> [TestCase] shaTestCases :: [(Int, String)] -> [TestCase]
shaTestCases l = map make l shaTestCases l = map make l
where where
make (n, knowngood) = make (n, knowngood) = TestCase key $ maybeSelectCmd key $
TestCase key $ maybeSelectCmd key $
zip (shacmds n) (repeat check) zip (shacmds n) (repeat check)
where where
key = "sha" ++ show n key = "sha" ++ show n

View file

@ -123,7 +123,7 @@ autoCopies file key vs a = Annex.getState Annex.auto >>= go
go True = do go True = do
numcopiesattr <- numCopies file numcopiesattr <- numCopies file
needed <- getNumCopies numcopiesattr needed <- getNumCopies numcopiesattr
(_, have) <- trustPartition UnTrusted =<< Remote.keyLocations key have <- trustExclude UnTrusted =<< Remote.keyLocations key
if length have `vs` needed then a else stop if length have `vs` needed then a else stop
autoCopiesWith :: FilePath -> Key -> (Int -> Int -> Bool) -> (Maybe Int -> CommandStart) -> CommandStart autoCopiesWith :: FilePath -> Key -> (Int -> Int -> Bool) -> (Maybe Int -> CommandStart) -> CommandStart
@ -134,7 +134,7 @@ autoCopiesWith file key vs a = do
auto numcopiesattr False = a numcopiesattr auto numcopiesattr False = a numcopiesattr
auto numcopiesattr True = do auto numcopiesattr True = do
needed <- getNumCopies numcopiesattr needed <- getNumCopies numcopiesattr
(_, have) <- trustPartition UnTrusted =<< Remote.keyLocations key have <- trustExclude UnTrusted =<< Remote.keyLocations key
if length have `vs` needed if length have `vs` needed
then a numcopiesattr then a numcopiesattr
else stop else stop

View file

@ -166,7 +166,8 @@ options = Option.common ++
"stop after the specified amount of time" "stop after the specified amount of time"
] ++ Option.matcher ] ++ Option.matcher
where where
setnumcopies v = Annex.changeState $ \s -> s { Annex.forcenumcopies = readish v } setnumcopies v = Annex.changeState $
\s -> s { Annex.forcenumcopies = readish v }
setgitconfig :: String -> Annex () setgitconfig :: String -> Annex ()
setgitconfig v = do setgitconfig v = do
newg <- inRepo $ Git.Config.store v newg <- inRepo $ Git.Config.store v

View file

@ -45,9 +45,7 @@ cmds_notreadonly = concat
cmds :: [Command] cmds :: [Command]
cmds = map adddirparam $ cmds_readonly ++ cmds_notreadonly cmds = map adddirparam $ cmds_readonly ++ cmds_notreadonly
where where
adddirparam c = c adddirparam c = c { cmdparamdesc = "DIRECTORY " ++ cmdparamdesc c }
{ cmdparamdesc = "DIRECTORY " ++ cmdparamdesc c
}
options :: [OptDescr (Annex ())] options :: [OptDescr (Annex ())]
options = Option.common ++ options = Option.common ++

View file

@ -144,8 +144,7 @@ runTransfer t file shouldretry a = do
| otherwise = do | otherwise = do
f <- fromRepo $ gitAnnexTmpLocation (transferKey t) f <- fromRepo $ gitAnnexTmpLocation (transferKey t)
liftIO $ catchDefaultIO 0 $ liftIO $ catchDefaultIO 0 $
fromIntegral . fileSize fromIntegral . fileSize <$> getFileStatus f
<$> getFileStatus f
{- Generates a callback that can be called as transfer progresses to update {- Generates a callback that can be called as transfer progresses to update
- the transfer info file. Also returns the file it'll be updating, and a - the transfer info file. Also returns the file it'll be updating, and a
@ -208,8 +207,7 @@ getTransfers = do
filter running $ zip transfers infos filter running $ zip transfers infos
where where
findfiles = liftIO . mapM dirContentsRecursive findfiles = liftIO . mapM dirContentsRecursive
=<< mapM (fromRepo . transferDir) =<< mapM (fromRepo . transferDir) [Download, Upload]
[Download, Upload]
running (_, i) = isJust i running (_, i) = isJust i
{- Gets failed transfers for a given remote UUID. -} {- Gets failed transfers for a given remote UUID. -}
@ -223,8 +221,7 @@ getFailedTransfers u = catMaybes <$> (liftIO . getpairs =<< concat <$> findfiles
(Just t, Just i) -> Just (t, i) (Just t, Just i) -> Just (t, i)
_ -> Nothing _ -> Nothing
findfiles = liftIO . mapM dirContentsRecursive findfiles = liftIO . mapM dirContentsRecursive
=<< mapM (fromRepo . failedTransferDir u) =<< mapM (fromRepo . failedTransferDir u) [Download, Upload]
[Download, Upload]
removeFailedTransfer :: Transfer -> Annex () removeFailedTransfer :: Transfer -> Annex ()
removeFailedTransfer t = do removeFailedTransfer t = do

View file

@ -88,9 +88,8 @@ trustMapLoad = do
Annex.changeState $ \s -> s { Annex.trustmap = Just m } Annex.changeState $ \s -> s { Annex.trustmap = Just m }
return m return m
where where
configuredtrust r = configuredtrust r = maybe Nothing (\l -> Just (Types.Remote.uuid r, l))
maybe Nothing (\l -> Just (Types.Remote.uuid r, l)) <$> <$> maybe Nothing readTrustLevel
maybe Nothing readTrustLevel
<$> getTrustLevel (Types.Remote.repo r) <$> getTrustLevel (Types.Remote.repo r)
{- Does not include forcetrust or git config values, just those from the {- Does not include forcetrust or git config values, just those from the

View file

@ -36,8 +36,7 @@ readUnusedLog prefix = do
, return M.empty , return M.empty
) )
where where
parse line = parse line = case (readish tag, file2key rest) of
case (readish tag, file2key rest) of
(Just num, Just key) -> Just (num, key) (Just num, Just key) -> Just (num, key)
_ -> Nothing _ -> Nothing
where where

View file

@ -167,7 +167,8 @@ checkPresent r bupr k
where where
params = params =
[ Params "show-ref --quiet --verify" [ Params "show-ref --quiet --verify"
, Param $ "refs/heads/" ++ bupRef k] , Param $ "refs/heads/" ++ bupRef k
]
{- Store UUID in the annex.uuid setting of the bup repository. -} {- Store UUID in the annex.uuid setting of the bup repository. -}
storeBupUUID :: UUID -> BupRepo -> Annex () storeBupUUID :: UUID -> BupRepo -> Annex ()

View file

@ -57,7 +57,6 @@ gen r u c = do
readonly = False, readonly = False,
remotetype = remote remotetype = remote
} }
where
type ChunkSize = Maybe Int64 type ChunkSize = Maybe Int64
@ -109,14 +108,14 @@ withCheckedFiles check (Just _) d k a = go $ locations d k
go [] = return False go [] = return False
go (f:fs) = do go (f:fs) = do
let chunkcount = chunkCount f let chunkcount = chunkCount f
use <- check chunkcount ifM (check chunkcount)
if use ( do
then do
count <- readcount chunkcount count <- readcount chunkcount
let chunks = take count $ chunkStream f let chunks = take count $ chunkStream f
ifM (all id <$> mapM check chunks) ifM (all id <$> mapM check chunks)
( a chunks , return False ) ( a chunks , return False )
else go fs , go fs
)
readcount f = fromMaybe (error $ "cannot parse " ++ f) readcount f = fromMaybe (error $ "cannot parse " ++ f)
. (readish :: String -> Maybe Int) . (readish :: String -> Maybe Int)
<$> readFile f <$> readFile f

View file

@ -67,8 +67,7 @@ runHooks r starthook stophook a = do
-- So, requiring idempotency is the right approach. -- So, requiring idempotency is the right approach.
run starthook run starthook
Annex.addCleanup (remoteid ++ "-stop-command") $ Annex.addCleanup (remoteid ++ "-stop-command") $ runstop lck
runstop lck
runstop lck = do runstop lck = do
-- Drop any shared lock we have, and take an -- Drop any shared lock we have, and take an
-- exclusive lock, without blocking. If the lock -- exclusive lock, without blocking. If the lock

View file

@ -1,6 +1,6 @@
{- git-annex remote access with ssh {- git-annex remote access with ssh
- -
- Copyright 2011.2012 Joey Hess <joey@kitenet.net> - Copyright 2011,2012 Joey Hess <joey@kitenet.net>
- -
- Licensed under the GNU GPL version 3 or higher. - Licensed under the GNU GPL version 3 or higher.
-} -}

View file

@ -65,8 +65,7 @@ hookSetup u c = do
hookEnv :: Key -> Maybe FilePath -> IO (Maybe [(String, String)]) hookEnv :: Key -> Maybe FilePath -> IO (Maybe [(String, String)])
hookEnv k f = Just <$> mergeenv (fileenv f ++ keyenv) hookEnv k f = Just <$> mergeenv (fileenv f ++ keyenv)
where where
mergeenv l = M.toList . mergeenv l = M.toList . M.union (M.fromList l)
M.union (M.fromList l)
<$> M.fromList <$> getEnvironment <$> M.fromList <$> getEnvironment
env s v = ("ANNEX_" ++ s, v) env s v = ("ANNEX_" ++ s, v)
keyenv = catMaybes keyenv = catMaybes
@ -94,9 +93,7 @@ runHook hooktype hook k f a = maybe (return False) run =<< lookupHook hooktype h
where where
run command = do run command = do
showOutput -- make way for hook output showOutput -- make way for hook output
ifM (liftIO $ ifM (liftIO $ boolSystemEnv "sh" [Param "-c", Param command] =<< hookEnv k f)
boolSystemEnv "sh" [Param "-c", Param command]
=<< hookEnv k f)
( a ( a
, do , do
warning $ hook ++ " hook exited nonzero!" warning $ hook ++ " hook exited nonzero!"

View file

@ -102,19 +102,16 @@ s3Setup u c = handlehost $ M.lookup "host" c
use archiveconfig use archiveconfig
where where
archiveconfig = archiveconfig =
-- hS3 does not pass through -- hS3 does not pass through x-archive-* headers
-- x-archive-* headers
M.mapKeys (replace "x-archive-" "x-amz-") $ M.mapKeys (replace "x-archive-" "x-amz-") $
-- encryption does not make sense here -- encryption does not make sense here
M.insert "encryption" "none" $ M.insert "encryption" "none" $
M.union c $ M.union c $
-- special constraints on key names -- special constraints on key names
M.insert "mungekeys" "ia" $ M.insert "mungekeys" "ia" $
-- bucket created only when files -- bucket created only when files are uploaded
-- are uploaded
M.insert "x-amz-auto-make-bucket" "1" $ M.insert "x-amz-auto-make-bucket" "1" $
-- no default bucket name; should -- no default bucket name; should be human-readable
-- be human-readable
M.delete "bucket" defaults M.delete "bucket" defaults
store :: Remote -> Key -> AssociatedFile -> MeterUpdate -> Annex Bool store :: Remote -> Key -> AssociatedFile -> MeterUpdate -> Annex Bool
@ -303,8 +300,8 @@ s3GetCreds c u = maybe fromcache (return . Just) =<< liftIO getenv
return $ Just (ak, sk) return $ Just (ak, sk)
_ -> do error "bad s3creds" _ -> do error "bad s3creds"
_ -> return Nothing _ -> return Nothing
decrypt s3creds cipher = lines <$> decrypt s3creds cipher = lines
withDecryptedContent cipher <$> withDecryptedContent cipher
(return $ L.pack $ fromB64 s3creds) (return $ L.pack $ fromB64 s3creds)
(return . L.unpack) (return . L.unpack)

View file

@ -112,9 +112,8 @@ prepFiltered a fs = do
matcher <- Limit.getMatcher matcher <- Limit.getMatcher
map (process matcher) <$> fs map (process matcher) <$> fs
where where
process matcher f = do process matcher f = ifM (matcher $ Annex.FileInfo f f)
ok <- matcher $ Annex.FileInfo f f ( a f , return Nothing )
if ok then a f else return Nothing
notSymlink :: FilePath -> IO Bool notSymlink :: FilePath -> IO Bool
notSymlink f = liftIO $ not . isSymbolicLink <$> getSymbolicLinkStatus f notSymlink f = liftIO $ not . isSymbolicLink <$> getSymbolicLinkStatus f