From 89f69251dd0113663b1995f56a9ce6d17be6e498 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 2 Dec 2015 15:57:30 -0400 Subject: 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. --- Config/Files.hs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'Config') 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. -} -- cgit v1.2.3