more OsPath conversion

Sponsored-by: k0ld
This commit is contained in:
Joey Hess 2025-02-01 14:06:38 -04:00
parent 474cf3bc8b
commit 71195cce13
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
33 changed files with 198 additions and 194 deletions

View file

@ -23,15 +23,14 @@ import Data.Time.Clock.POSIX
import System.PosixCompat.Files (modificationTime)
import qualified Data.Map as M
import qualified Data.Set as S
import qualified System.FilePath.ByteString as P
repoCheap :: Git.Repo -> Bool
repoCheap = not . Git.repoIsUrl
localpathCalc :: Git.Repo -> Maybe FilePath
localpathCalc :: Git.Repo -> Maybe OsPath
localpathCalc r
| not (Git.repoIsLocal r) && not (Git.repoIsLocalUnknown r) = Nothing
| otherwise = Just $ fromRawFilePath $ Git.repoPath r
| otherwise = Just $ Git.repoPath r
{- Checks relatively inexpensively if a repository is available for use. -}
repoAvail :: Git.Repo -> Annex Availability
@ -63,8 +62,11 @@ guardUsable r fallback a
gitRepoInfo :: Remote -> Annex [(String, String)]
gitRepoInfo r = do
d <- fromRepo Git.localGitDir
mtimes <- liftIO $ mapM (\p -> modificationTime <$> R.getFileStatus p)
=<< emptyWhenDoesNotExist (dirContentsRecursive (d P.</> "refs" P.</> "remotes" P.</> encodeBS (Remote.name r)))
let refsdir = d </> literalOsPath "refs"
</> literalOsPath "remotes"
</> toOsPath (Remote.name r)
mtimes <- liftIO $ mapM (\p -> modificationTime <$> R.getFileStatus (fromOsPath p))
=<< emptyWhenDoesNotExist (dirContentsRecursive refsdir)
let lastsynctime = case mtimes of
[] -> "never"
_ -> show $ posixSecondsToUTCTime $ realToFrac $ maximum mtimes