webapp: New preferences page allows enabling/disabling debug logging at runtime, as well as configuring numcopies and diskreserve.

This commit is contained in:
Joey Hess 2013-03-03 17:07:27 -04:00
parent d7ad02f893
commit 08bdea7e52
13 changed files with 174 additions and 58 deletions

View file

@ -8,6 +8,7 @@
module Locations.UserConfig where
import Common
import Utility.TempFile
import Utility.FreeDesktop
{- ~/.config/git-annex/file -}
@ -19,6 +20,31 @@ userConfigFile file = do
autoStartFile :: IO FilePath
autoStartFile = userConfigFile "autostart"
{- Returns anything listed in the autostart file (which may not exist). -}
readAutoStartFile :: IO [FilePath]
readAutoStartFile = do
f <- autoStartFile
nub . lines <$> catchDefaultIO "" (readFile f)
{- Adds a directory to the autostart file. -}
addAutoStartFile :: FilePath -> IO ()
addAutoStartFile path = do
dirs <- readAutoStartFile
when (path `notElem` dirs) $ do
f <- autoStartFile
createDirectoryIfMissing True (parentDir f)
viaTmp writeFile f $ unlines $ dirs ++ [path]
{- Removes a directory from the autostart file. -}
removeAutoStartFile :: FilePath -> IO ()
removeAutoStartFile path = do
dirs <- readAutoStartFile
when (path `elem` dirs) $ do
f <- autoStartFile
createDirectoryIfMissing True (parentDir f)
viaTmp writeFile f $ unlines $
filter (not . equalFilePath path) dirs
{- The path to git-annex is written here; which is useful when cabal
- has installed it to some aweful non-PATH location. -}
programFile :: IO FilePath