better ~/ handling
This commit is contained in:
parent
112ce4f49c
commit
9a038b4a9b
3 changed files with 12 additions and 6 deletions
|
@ -64,12 +64,9 @@ webAppThread mst dstatus transferqueue postfirstrun onstartup = do
|
|||
Just st -> go port webapp =<< runThreadState st (fromRepo gitAnnexHtmlShim)
|
||||
where
|
||||
getreldir Nothing = return Nothing
|
||||
getreldir (Just st) = do
|
||||
dir <- absPath =<< runThreadState st (fromRepo repoPath)
|
||||
home <- myHomeDir
|
||||
return $ Just $ if dirContains home dir
|
||||
then relPathDirToFile home dir
|
||||
else dir
|
||||
getreldir (Just st) = Just <$>
|
||||
(relHome =<< absPath
|
||||
=<< runThreadState st (fromRepo repoPath))
|
||||
go port webapp htmlshim = do
|
||||
writeHtmlShim webapp port htmlshim
|
||||
maybe noop (\a -> a (myUrl webapp port "/") htmlshim) onstartup
|
||||
|
|
|
@ -22,6 +22,7 @@ import qualified Git.Construct
|
|||
import qualified Git.Config
|
||||
import qualified Annex
|
||||
import Locations.UserConfig
|
||||
import Utility.FreeDesktop
|
||||
|
||||
import Yesod
|
||||
import Data.Text (Text)
|
||||
|
|
|
@ -132,6 +132,14 @@ runPreserveOrder a files = preserveOrder files <$> a files
|
|||
myHomeDir :: IO FilePath
|
||||
myHomeDir = homeDirectory <$> (getUserEntryForID =<< getEffectiveUserID)
|
||||
|
||||
{- Converts paths in the home directory to use ~/ -}
|
||||
relHome :: FilePath -> IO String
|
||||
relHome path = do
|
||||
home <- myHomeDir
|
||||
return $ if dirContains home path
|
||||
then "~/" ++ relPathDirToFile home path
|
||||
else path
|
||||
|
||||
{- Checks if a command is available in PATH. -}
|
||||
inPath :: String -> IO Bool
|
||||
inPath command = getSearchPath >>= anyM indir
|
||||
|
|
Loading…
Add table
Reference in a new issue