summaryrefslogtreecommitdiff
path: root/Config
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2015-12-02 15:57:30 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2015-12-02 15:57:30 -0400
commit89f69251dd0113663b1995f56a9ce6d17be6e498 (patch)
treeec4caa7cc827dfaeb5b903024b1e478670daf1a8 /Config
parentb38a482dd99a4f16c9752190e929b7726aba4c83 (diff)
webapp: Fix bugs that could result in a relative path such as "." being written to ~/.config/git-annex/autostart
and ignore any such relative paths in the file This was a reversion caused by the relative path changes in 5.20150113.
Diffstat (limited to 'Config')
-rw-r--r--Config/Files.hs15
1 files changed, 11 insertions, 4 deletions
diff --git a/Config/Files.hs b/Config/Files.hs
index 294eae22a..8f8b4c115 100644
--- a/Config/Files.hs
+++ b/Config/Files.hs
@@ -26,8 +26,11 @@ autoStartFile = userConfigFile "autostart"
readAutoStartFile :: IO [FilePath]
readAutoStartFile = do
f <- autoStartFile
- nub . map dropTrailingPathSeparator . lines
+ filter valid . nub . map dropTrailingPathSeparator . lines
<$> catchDefaultIO "" (readFile f)
+ where
+ -- Ignore any relative paths; some old buggy versions added eg "."
+ valid = isAbsolute
modifyAutoStartFile :: ([FilePath] -> [FilePath]) -> IO ()
modifyAutoStartFile func = do
@@ -42,12 +45,16 @@ modifyAutoStartFile func = do
- present, it's moved to the top, so it will be used as the default
- when opening the webapp. -}
addAutoStartFile :: FilePath -> IO ()
-addAutoStartFile path = modifyAutoStartFile $ (:) path
+addAutoStartFile path = do
+ path' <- absPath path
+ modifyAutoStartFile $ (:) path'
{- Removes a directory from the autostart file. -}
removeAutoStartFile :: FilePath -> IO ()
-removeAutoStartFile path = modifyAutoStartFile $
- filter (not . equalFilePath path)
+removeAutoStartFile path = do
+ path' <- absPath path
+ modifyAutoStartFile $
+ filter (not . equalFilePath path')
{- The path to git-annex is written here; which is useful when cabal
- has installed it to some awful non-PATH location. -}