more OsPath conversion
Git.Types now uses it, as does TopFilePath, making for plenty of new compile errors needing fixing. Sponsored-by: Brock Spratlen
This commit is contained in:
parent
12660314f1
commit
ea775baccd
22 changed files with 159 additions and 163 deletions
|
@ -9,28 +9,27 @@
|
|||
|
||||
module Config.Files where
|
||||
|
||||
import Common
|
||||
import Utility.FreeDesktop
|
||||
import Utility.Exception
|
||||
|
||||
import System.FilePath
|
||||
|
||||
{- ~/.config/git-annex/file -}
|
||||
userConfigFile :: FilePath -> IO FilePath
|
||||
userConfigFile :: OsPath -> IO OsPath
|
||||
userConfigFile file = do
|
||||
dir <- userConfigDir
|
||||
return $ dir </> "git-annex" </> file
|
||||
dir <- toOsPath <$> userConfigDir
|
||||
return $ dir </> literalOsPath "git-annex" </> file
|
||||
|
||||
autoStartFile :: IO FilePath
|
||||
autoStartFile = userConfigFile "autostart"
|
||||
autoStartFile :: IO OsPath
|
||||
autoStartFile = userConfigFile (literalOsPath "autostart")
|
||||
|
||||
{- The path to git-annex is written here; which is useful when something
|
||||
- has installed it to some awful non-PATH location. -}
|
||||
programFile :: IO FilePath
|
||||
programFile = userConfigFile "program"
|
||||
programFile :: IO OsPath
|
||||
programFile = userConfigFile (literalOsPath "program")
|
||||
|
||||
{- A .noannex file in a git repository prevents git-annex from
|
||||
- initializing that repository. The content of the file is returned. -}
|
||||
noAnnexFileContent :: Maybe FilePath -> IO (Maybe String)
|
||||
noAnnexFileContent :: Maybe OsPath -> IO (Maybe String)
|
||||
noAnnexFileContent repoworktree = case repoworktree of
|
||||
Nothing -> return Nothing
|
||||
Just wt -> catchMaybeIO (readFile (wt </> ".noannex"))
|
||||
Just wt -> catchMaybeIO (readFile (fromOsPath (wt </> literalOsPath ".noannex")))
|
||||
|
|
|
@ -14,38 +14,37 @@ import Config.Files
|
|||
import Utility.Tmp
|
||||
|
||||
{- Returns anything listed in the autostart file (which may not exist). -}
|
||||
readAutoStartFile :: IO [FilePath]
|
||||
readAutoStartFile :: IO [OsPath]
|
||||
readAutoStartFile = do
|
||||
f <- autoStartFile
|
||||
filter valid . nub . map dropTrailingPathSeparator . lines
|
||||
<$> catchDefaultIO "" (readFile f)
|
||||
filter valid . nub . map (dropTrailingPathSeparator . toOsPath) . lines
|
||||
<$> catchDefaultIO "" (readFile (fromOsPath f))
|
||||
where
|
||||
-- Ignore any relative paths; some old buggy versions added eg "."
|
||||
valid = isAbsolute
|
||||
|
||||
modifyAutoStartFile :: ([FilePath] -> [FilePath]) -> IO ()
|
||||
modifyAutoStartFile :: ([OsPath] -> [OsPath]) -> IO ()
|
||||
modifyAutoStartFile func = do
|
||||
dirs <- readAutoStartFile
|
||||
let dirs' = nubBy equalFilePath $ func dirs
|
||||
when (dirs' /= dirs) $ do
|
||||
f <- autoStartFile
|
||||
createDirectoryIfMissing True $
|
||||
fromRawFilePath (parentDir (toRawFilePath f))
|
||||
createDirectoryIfMissing True (parentDir f)
|
||||
viaTmp (writeFile . fromRawFilePath . fromOsPath)
|
||||
(toOsPath (toRawFilePath f))
|
||||
(unlines dirs')
|
||||
(toOsPath f)
|
||||
(unlines (map fromOsPath dirs'))
|
||||
|
||||
{- Adds a directory to the autostart file. If the directory is already
|
||||
- present, it's moved to the top, so it will be used as the default
|
||||
- when opening the webapp. -}
|
||||
addAutoStartFile :: FilePath -> IO ()
|
||||
addAutoStartFile :: OsPath -> IO ()
|
||||
addAutoStartFile path = do
|
||||
path' <- fromRawFilePath <$> absPath (toRawFilePath path)
|
||||
path' <- absPath path
|
||||
modifyAutoStartFile $ (:) path'
|
||||
|
||||
{- Removes a directory from the autostart file. -}
|
||||
removeAutoStartFile :: FilePath -> IO ()
|
||||
removeAutoStartFile :: OsPath -> IO ()
|
||||
removeAutoStartFile path = do
|
||||
path' <- fromRawFilePath <$> absPath (toRawFilePath path)
|
||||
path' <- absPath path
|
||||
modifyAutoStartFile $
|
||||
filter (not . equalFilePath path')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue