summaryrefslogtreecommitdiff
path: root/Locations
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2013-03-03 17:07:27 -0400
committerGravatar Joey Hess <joey@kitenet.net>2013-03-03 17:07:27 -0400
commit3aa991bc7961433c0b888a2ab184b22942e5de79 (patch)
tree87d9649c8519d3d49b8128c9b343b14119db45f2 /Locations
parent19a17dddb2baad5fbfa3203449ac416b30b8fa1b (diff)
webapp: New preferences page allows enabling/disabling debug logging at runtime, as well as configuring numcopies and diskreserve.
Diffstat (limited to 'Locations')
-rw-r--r--Locations/UserConfig.hs26
1 files changed, 26 insertions, 0 deletions
diff --git a/Locations/UserConfig.hs b/Locations/UserConfig.hs
index 3a6a27e91..429ed8fd5 100644
--- a/Locations/UserConfig.hs
+++ b/Locations/UserConfig.hs
@@ -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