From e9f43c07f9e18fc008c9b843d82b813bdc9c203e Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 2 Dec 2015 15:57:30 -0400 Subject: [PATCH] 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. --- Assistant/WebApp/Configurators/Preferences.hs | 2 +- Config/Files.hs | 15 ++++++++---- debian/changelog | 4 ++++ ...___repository_shows_up_when_switching.mdwn | 1 + ..._ffe8e30474e87e8cfa5aee2a3acb0952._comment | 24 +++++++++++++++++++ 5 files changed, 41 insertions(+), 5 deletions(-) create mode 100644 doc/bugs/A_weird___34__.__34___repository_shows_up_when_switching/comment_2_ffe8e30474e87e8cfa5aee2a3acb0952._comment diff --git a/Assistant/WebApp/Configurators/Preferences.hs b/Assistant/WebApp/Configurators/Preferences.hs index 98b67eb34a..4b9f5817c3 100644 --- a/Assistant/WebApp/Configurators/Preferences.hs +++ b/Assistant/WebApp/Configurators/Preferences.hs @@ -118,5 +118,5 @@ postPreferencesR = page "Preferences" (Just Configuration) $ do inAutoStartFile :: Annex Bool inAutoStartFile = do - here <- fromRepo Git.repoPath + here <- liftIO . absPath =<< fromRepo Git.repoPath any (`equalFilePath` here) <$> liftIO readAutoStartFile diff --git a/Config/Files.hs b/Config/Files.hs index 294eae22aa..8f8b4c1158 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. -} diff --git a/debian/changelog b/debian/changelog index 42295c91dc..ea54b99b4e 100644 --- a/debian/changelog +++ b/debian/changelog @@ -14,6 +14,10 @@ git-annex (5.20151117) UNRELEASED; urgency=medium * addurl, importfeed: Changed to honor annex.largefiles settings, when the content of the url is downloaded. (Not when using --fast or --relaxed.) + * 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. -- Joey Hess Mon, 16 Nov 2015 16:49:34 -0400 diff --git a/doc/bugs/A_weird___34__.__34___repository_shows_up_when_switching.mdwn b/doc/bugs/A_weird___34__.__34___repository_shows_up_when_switching.mdwn index 4bb1fc0e25..357517b0e4 100644 --- a/doc/bugs/A_weird___34__.__34___repository_shows_up_when_switching.mdwn +++ b/doc/bugs/A_weird___34__.__34___repository_shows_up_when_switching.mdwn @@ -23,3 +23,4 @@ there is nothing relevant to this error in there unfortunately. ### Have you had any luck using git-annex before? (Sometimes we get tired of reading bug reports all day and a lil' positive end note does wonders) +> [[fixed|done]] --[[Joey]] diff --git a/doc/bugs/A_weird___34__.__34___repository_shows_up_when_switching/comment_2_ffe8e30474e87e8cfa5aee2a3acb0952._comment b/doc/bugs/A_weird___34__.__34___repository_shows_up_when_switching/comment_2_ffe8e30474e87e8cfa5aee2a3acb0952._comment new file mode 100644 index 0000000000..e83842dead --- /dev/null +++ b/doc/bugs/A_weird___34__.__34___repository_shows_up_when_switching/comment_2_ffe8e30474e87e8cfa5aee2a3acb0952._comment @@ -0,0 +1,24 @@ +[[!comment format=mdwn + username="joey" + subject="""comment 2""" + date="2015-12-02T19:36:14Z" + content=""" +Found this in the changelog: + + * webapp: When adding another local repository, and combining it + with the current repository, the new repository's remote path + was set to "." rather than the path to the current repository. + This was a reversion caused by the relative path changes in 5.20150113. + +I guess this is a similar problem, although it seems that the "." in your case +made it into `~/.config/git-annex/autostart` + +I found two ways to do that. One is to tell the webapp to make a repository, and +enter "." as the repository location. The other, which is probably what you +did, is to go to Configuration -> Preferences and uncheck "Auto start", save +and then go back and check it. This wrongly puts in a "." instead of the full +repo path. + +I've fixed all code paths to force absolute paths in the autostart file, +and made any relative paths that got in there be ignored. +"""]]