more OsPath conversion

Sponsored-by: mycroft
This commit is contained in:
Joey Hess 2025-01-28 15:46:00 -04:00
parent 917c43f31f
commit 22c2451e26
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
11 changed files with 46 additions and 44 deletions

View file

@ -18,14 +18,14 @@ import Types.UUID
import Types.FileMatcher
import Git.FilePath
import Git.Quote (StringContainingQuotedPath(..))
import Utility.FileSystemEncoding
import Utility.OsPath
data ActionItem
= ActionItemAssociatedFile AssociatedFile Key
| ActionItemKey Key
| ActionItemBranchFilePath BranchFilePath Key
| ActionItemFailedTransfer Transfer TransferInfo
| ActionItemTreeFile RawFilePath
| ActionItemTreeFile OsPath
| ActionItemUUID UUID StringContainingQuotedPath
-- ^ UUID with a description or name of the repository
| ActionItemOther (Maybe StringContainingQuotedPath)
@ -46,10 +46,10 @@ instance MkActionItem (AssociatedFile, Key) where
instance MkActionItem (Key, AssociatedFile) where
mkActionItem = uncurry $ flip ActionItemAssociatedFile
instance MkActionItem (Key, RawFilePath) where
instance MkActionItem (Key, OsPath) where
mkActionItem (key, file) = ActionItemAssociatedFile (AssociatedFile (Just file)) key
instance MkActionItem (RawFilePath, Key) where
instance MkActionItem (OsPath, Key) where
mkActionItem (file, key) = mkActionItem (key, file)
instance MkActionItem Key where
@ -97,7 +97,7 @@ actionItemKey (ActionItemUUID _ _) = Nothing
actionItemKey (ActionItemOther _) = Nothing
actionItemKey (OnlyActionOn _ ai) = actionItemKey ai
actionItemFile :: ActionItem -> Maybe RawFilePath
actionItemFile :: ActionItem -> Maybe OsPath
actionItemFile (ActionItemAssociatedFile (AssociatedFile af) _) = af
actionItemFile (ActionItemTreeFile f) = Just f
actionItemFile (ActionItemUUID _ _) = Nothing

View file

@ -14,7 +14,7 @@ import Types.Mime
import Types.RepoSize (LiveUpdate)
import Utility.Matcher (Matcher, Token, MatchDesc)
import Utility.FileSize
import Utility.FileSystemEncoding
import Utility.OsPath
import Control.Monad.IO.Class
import qualified Data.Map as M
@ -27,10 +27,10 @@ data MatchInfo
| MatchingUserInfo UserProvidedInfo
data FileInfo = FileInfo
{ contentFile :: RawFilePath
{ contentFile :: OsPath
-- ^ path to a file containing the content, for operations
-- that examine it
, matchFile :: RawFilePath
, matchFile :: OsPath
-- ^ filepath to match on; may be relative to top of repo or cwd,
-- depending on how globs in preferred content expressions
-- are intended to be matched
@ -39,7 +39,7 @@ data FileInfo = FileInfo
}
data ProvidedInfo = ProvidedInfo
{ providedFilePath :: Maybe RawFilePath
{ providedFilePath :: Maybe OsPath
-- ^ filepath to match on, should not be accessed from disk.
, providedKey :: Maybe Key
, providedFileSize :: Maybe FileSize
@ -48,7 +48,7 @@ data ProvidedInfo = ProvidedInfo
, providedLinkType :: Maybe LinkType
}
keyMatchInfoWithoutContent :: Key -> RawFilePath -> MatchInfo
keyMatchInfoWithoutContent :: Key -> OsPath -> MatchInfo
keyMatchInfoWithoutContent key file = MatchingInfo $ ProvidedInfo
{ providedFilePath = Just file
, providedKey = Just key

View file

@ -28,6 +28,8 @@ module Types.Key (
parseKeyVariety,
) where
import Utility.OsPath
import qualified Data.ByteString as S
import qualified Data.ByteString.Short as S (ShortByteString, toShort, fromShort)
import qualified Data.ByteString.Char8 as S8
@ -36,7 +38,6 @@ import Data.ByteString.Builder
import Data.ByteString.Builder.Extra
import qualified Data.Attoparsec.ByteString as A
import qualified Data.Attoparsec.ByteString.Char8 as A8
import Utility.FileSystemEncoding
import Data.List
import Data.Char
import System.Posix.Types
@ -202,7 +203,7 @@ splitKeyNameExtension' :: S.ByteString -> (S.ByteString, S.ByteString)
splitKeyNameExtension' keyname = S8.span (/= '.') keyname
{- A filename may be associated with a Key. -}
newtype AssociatedFile = AssociatedFile (Maybe RawFilePath)
newtype AssociatedFile = AssociatedFile (Maybe OsPath)
deriving (Show, Eq, Ord)
{- There are several different varieties of keys. -}

View file

@ -19,7 +19,7 @@ import Types.Direction
import Utility.PID
import Utility.QuickCheck
import Utility.Url
import Utility.FileSystemEncoding
import Utility.OsPath
import Data.Time.Clock.POSIX
import Control.Concurrent
@ -99,7 +99,7 @@ class Transferrable t where
descTransfrerrable :: t -> Maybe String
instance Transferrable AssociatedFile where
descTransfrerrable (AssociatedFile af) = fromRawFilePath <$> af
descTransfrerrable (AssociatedFile af) = fromOsPath <$> af
instance Transferrable URLString where
descTransfrerrable = Just