diff options
author | Joey Hess <joeyh@joeyh.name> | 2016-10-06 13:54:52 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2016-10-06 13:54:52 -0400 |
commit | b40d441c52f37584653e74fada9906cc8105c9f7 (patch) | |
tree | 737396d6ab61212cad52555c7bc99dedd167b330 /keysafe.hs | |
parent | 54d3bfbb98958cb49399f1a7f092fa43593ef4c8 (diff) | |
download | keysafe-b40d441c52f37584653e74fada9906cc8105c9f7.tar.gz |
move level from Server to Storage
This allows local storage locations to have levels too, and also get
shuffled nicely.
This commit was sponsored by Ethan Aubin.
Diffstat (limited to 'keysafe.hs')
-rw-r--r-- | keysafe.hs | 21 |
1 files changed, 9 insertions, 12 deletions
@@ -20,7 +20,6 @@ import Cost import SecretKey import Share import Storage -import Servers import Types.Server import BackupLog import AutoStart @@ -86,7 +85,7 @@ dispatch cmdline ui tunables possibletunables = do go (CmdLine.Chaff hn) _ = storeChaff hn (CmdLine.serverPort (CmdLine.serverConfig cmdline)) (CmdLine.chaffMaxDelay cmdline) - go CmdLine.CheckServers _ = checkServers + go CmdLine.CheckServers _ = checkServers cmdline go CmdLine.Benchmark _ = benchmarkTunables tunables go CmdLine.Test _ = @@ -361,11 +360,7 @@ userName = do return $ Name $ BU8.fromString $ takeWhile (/= ',') (userGecos u) cmdLineStorageLocations :: CmdLine.CmdLine -> IO StorageLocations -cmdLineStorageLocations cmdline - | CmdLine.localstorage cmdline = return (localStorageLocations lsd) - | otherwise = networkStorageLocations lsd - where - lsd = CmdLine.localstoragedirectory cmdline +cmdLineStorageLocations = networkStorageLocations . CmdLine.localstoragedirectory getPasswordEntropy :: Password -> Name -> IO (Entropy UnknownPassword) getPasswordEntropy password name = do @@ -409,15 +404,17 @@ autoStart cmdline tunables ui = do else storeBackupLog =<< mkBackupLog (BackupSkipped (GpgKey kid)) -checkServers :: IO () -checkServers = do - say $ "Checking " ++ show (length networkServers) ++ " servers concurrently; please wait..." - results <- mapConcurrently check networkServers +checkServers :: CmdLine.CmdLine -> IO () +checkServers cmdline = do + StorageLocations sls <- cmdLineStorageLocations cmdline + let serverlist = mapMaybe getServer sls + say $ "Checking " ++ show (length serverlist) ++ " servers concurrently; please wait..." + results <- mapConcurrently check serverlist mapM_ displayresult results case filter failed results of [] -> return () l - | length l == length networkServers -> + | length l == length serverlist -> error "Failed to connect to any servers. Perhaps TOR is not running?" | otherwise -> error $ "Failed to connect to some servers: " |