more OsPath conversion
Sponsored-by: k0ld
This commit is contained in:
parent
474cf3bc8b
commit
71195cce13
33 changed files with 198 additions and 194 deletions
|
@ -47,11 +47,9 @@ import Git.FilePath
|
|||
import qualified Git.DiffTree as DiffTree
|
||||
import Logs
|
||||
import qualified Logs.ContentIdentifier as Log
|
||||
import qualified Utility.RawFilePath as R
|
||||
|
||||
import Database.Persist.Sql hiding (Key)
|
||||
import Database.Persist.TH
|
||||
import qualified System.FilePath.ByteString as P
|
||||
|
||||
#if MIN_VERSION_persistent_sqlite(2,13,3)
|
||||
import Database.RawFilePath
|
||||
|
@ -99,14 +97,14 @@ openDb :: Annex ContentIdentifierHandle
|
|||
openDb = do
|
||||
dbdir <- calcRepo' gitAnnexContentIdentifierDbDir
|
||||
let db = dbdir </> literalOsPath "db"
|
||||
isnew <- liftIO $ not <$> doesDirectoryPathExist db
|
||||
isnew <- liftIO $ not <$> doesDirectoryExist db
|
||||
if isnew
|
||||
then initDb db $ void $
|
||||
runMigrationSilent migrateContentIdentifier
|
||||
-- Migrate from old versions of database, which had buggy
|
||||
-- and suboptimal uniqueness constraints.
|
||||
#if MIN_VERSION_persistent_sqlite(2,13,3)
|
||||
else liftIO $ runSqlite' db $ void $
|
||||
else liftIO $ runSqlite' (fromOsPath db) $ void $
|
||||
runMigrationSilent migrateContentIdentifier
|
||||
#else
|
||||
else liftIO $ runSqlite (T.pack (fromRawFilePath db)) $ void $
|
||||
|
|
|
@ -58,11 +58,9 @@ import Git.Types
|
|||
import Git.Sha
|
||||
import Git.FilePath
|
||||
import qualified Git.DiffTree
|
||||
import qualified Utility.RawFilePath as R
|
||||
|
||||
import Database.Persist.Sql hiding (Key)
|
||||
import Database.Persist.TH
|
||||
import qualified System.FilePath.ByteString as P
|
||||
|
||||
data ExportHandle = ExportHandle H.DbQueue UUID
|
||||
|
||||
|
@ -98,8 +96,8 @@ ExportTreeCurrent
|
|||
openDb :: UUID -> Annex ExportHandle
|
||||
openDb u = do
|
||||
dbdir <- calcRepo' (gitAnnexExportDbDir u)
|
||||
let db = dbdir P.</> "db"
|
||||
unlessM (liftIO $ R.doesPathExist db) $ do
|
||||
let db = dbdir </> literalOsPath "db"
|
||||
unlessM (liftIO $ doesDirectoryExist db) $ do
|
||||
initDb db $ void $
|
||||
runMigrationSilent migrateExport
|
||||
h <- liftIO $ H.openDbQueue db "exported"
|
||||
|
@ -136,26 +134,27 @@ addExportedLocation :: ExportHandle -> Key -> ExportLocation -> IO ()
|
|||
addExportedLocation h k el = queueDb h $ do
|
||||
void $ insertUniqueFast $ Exported k ef
|
||||
let edirs = map
|
||||
(\ed -> ExportedDirectory (SByteString (fromExportDirectory ed)) ef)
|
||||
(\ed -> ExportedDirectory (SByteString (fromOsPath (fromExportDirectory ed))) ef)
|
||||
(exportDirectories el)
|
||||
putMany edirs
|
||||
where
|
||||
ef = SByteString (fromExportLocation el)
|
||||
ef = SByteString (fromOsPath (fromExportLocation el))
|
||||
|
||||
removeExportedLocation :: ExportHandle -> Key -> ExportLocation -> IO ()
|
||||
removeExportedLocation h k el = queueDb h $ do
|
||||
deleteWhere [ExportedKey ==. k, ExportedFile ==. ef]
|
||||
let subdirs = map (SByteString . fromExportDirectory)
|
||||
let subdirs = map
|
||||
(SByteString . fromOsPath . fromExportDirectory)
|
||||
(exportDirectories el)
|
||||
deleteWhere [ExportedDirectoryFile ==. ef, ExportedDirectorySubdir <-. subdirs]
|
||||
where
|
||||
ef = SByteString (fromExportLocation el)
|
||||
ef = SByteString (fromOsPath (fromExportLocation el))
|
||||
|
||||
{- Note that this does not see recently queued changes. -}
|
||||
getExportedLocation :: ExportHandle -> Key -> IO [ExportLocation]
|
||||
getExportedLocation (ExportHandle h _) k = H.queryDbQueue h $ do
|
||||
l <- selectList [ExportedKey ==. k] []
|
||||
return $ map (mkExportLocation . (\(SByteString f) -> f) . exportedFile . entityVal) l
|
||||
return $ map (mkExportLocation . (\(SByteString f) -> toOsPath f) . exportedFile . entityVal) l
|
||||
|
||||
{- Note that this does not see recently queued changes. -}
|
||||
isExportDirectoryEmpty :: ExportHandle -> ExportDirectory -> IO Bool
|
||||
|
@ -163,13 +162,13 @@ isExportDirectoryEmpty (ExportHandle h _) d = H.queryDbQueue h $ do
|
|||
l <- selectList [ExportedDirectorySubdir ==. ed] []
|
||||
return $ null l
|
||||
where
|
||||
ed = SByteString $ fromExportDirectory d
|
||||
ed = SByteString $ fromOsPath $ fromExportDirectory d
|
||||
|
||||
{- Get locations in the export that might contain a key. -}
|
||||
getExportTree :: ExportHandle -> Key -> IO [ExportLocation]
|
||||
getExportTree (ExportHandle h _) k = H.queryDbQueue h $ do
|
||||
l <- selectList [ExportTreeKey ==. k] []
|
||||
return $ map (mkExportLocation . (\(SByteString f) -> f) . exportTreeFile . entityVal) l
|
||||
return $ map (mkExportLocation . (\(SByteString f) -> toOsPath f) . exportTreeFile . entityVal) l
|
||||
|
||||
{- Get keys that might be currently exported to a location.
|
||||
-
|
||||
|
@ -180,19 +179,19 @@ getExportTreeKey (ExportHandle h _) el = H.queryDbQueue h $ do
|
|||
map (exportTreeKey . entityVal)
|
||||
<$> selectList [ExportTreeFile ==. ef] []
|
||||
where
|
||||
ef = SByteString (fromExportLocation el)
|
||||
ef = SByteString (fromOsPath (fromExportLocation el))
|
||||
|
||||
addExportTree :: ExportHandle -> Key -> ExportLocation -> IO ()
|
||||
addExportTree h k loc = queueDb h $
|
||||
void $ insertUniqueFast $ ExportTree k ef
|
||||
where
|
||||
ef = SByteString (fromExportLocation loc)
|
||||
ef = SByteString (fromOsPath (fromExportLocation loc))
|
||||
|
||||
removeExportTree :: ExportHandle -> Key -> ExportLocation -> IO ()
|
||||
removeExportTree h k loc = queueDb h $
|
||||
deleteWhere [ExportTreeKey ==. k, ExportTreeFile ==. ef]
|
||||
where
|
||||
ef = SByteString (fromExportLocation loc)
|
||||
ef = SByteString (fromOsPath (fromExportLocation loc))
|
||||
|
||||
-- An action that is passed the old and new values that were exported,
|
||||
-- and updates state.
|
||||
|
|
|
@ -40,11 +40,9 @@ import Logs.MetaData
|
|||
import Types.MetaData
|
||||
import Annex.MetaData.StandardFields
|
||||
import Annex.LockFile
|
||||
import qualified Utility.RawFilePath as R
|
||||
|
||||
import Database.Persist.Sql hiding (Key)
|
||||
import Database.Persist.TH
|
||||
import qualified System.FilePath.ByteString as P
|
||||
import qualified Data.ByteString as B
|
||||
import qualified Data.Set as S
|
||||
|
||||
|
@ -75,8 +73,8 @@ AnnexBranch
|
|||
openDb :: Annex ImportFeedDbHandle
|
||||
openDb = do
|
||||
dbdir <- calcRepo' gitAnnexImportFeedDbDir
|
||||
let db = dbdir P.</> "db"
|
||||
isnew <- liftIO $ not <$> R.doesPathExist db
|
||||
let db = dbdir </> literalOsPath "db"
|
||||
isnew <- liftIO $ not <$> doesDirectoryExist db
|
||||
when isnew $
|
||||
initDb db $ void $
|
||||
runMigrationSilent migrateImportFeed
|
||||
|
|
|
@ -54,11 +54,10 @@ import Git.Branch (writeTreeQuiet, update')
|
|||
import qualified Git.Ref
|
||||
import Config
|
||||
import Config.Smudge
|
||||
import qualified Utility.RawFilePath as R
|
||||
import qualified Utility.OsString as OS
|
||||
|
||||
import qualified Data.ByteString as S
|
||||
import qualified Data.ByteString.Char8 as S8
|
||||
import qualified System.FilePath.ByteString as P
|
||||
import Control.Concurrent.Async
|
||||
|
||||
{- Runs an action that reads from the database.
|
||||
|
@ -129,8 +128,8 @@ openDb forwrite _ = do
|
|||
lck <- calcRepo' gitAnnexKeysDbLock
|
||||
catchPermissionDenied permerr $ withExclusiveLock lck $ do
|
||||
dbdir <- calcRepo' gitAnnexKeysDbDir
|
||||
let db = dbdir P.</> "db"
|
||||
dbexists <- liftIO $ R.doesPathExist db
|
||||
let db = dbdir </> literalOsPath "db"
|
||||
dbexists <- liftIO $ doesDirectoryExist db
|
||||
case dbexists of
|
||||
True -> open db False
|
||||
False -> do
|
||||
|
@ -182,7 +181,7 @@ emptyWhenBare a = ifM isBareRepo
|
|||
)
|
||||
|
||||
{- Include a known associated file along with any recorded in the database. -}
|
||||
getAssociatedFilesIncluding :: AssociatedFile -> Key -> Annex [RawFilePath]
|
||||
getAssociatedFilesIncluding :: AssociatedFile -> Key -> Annex [OsPath]
|
||||
getAssociatedFilesIncluding afile k = emptyWhenBare $ do
|
||||
g <- Annex.gitRepo
|
||||
l <- map (`fromTopFilePath` g) <$> getAssociatedFiles k
|
||||
|
@ -201,7 +200,7 @@ removeAssociatedFile k = runWriterIO AssociatedTable .
|
|||
SQL.removeAssociatedFile k
|
||||
|
||||
{- Stats the files, and stores their InodeCaches. -}
|
||||
storeInodeCaches :: Key -> [RawFilePath] -> Annex ()
|
||||
storeInodeCaches :: Key -> [OsPath] -> Annex ()
|
||||
storeInodeCaches k fs = withTSDelta $ \d ->
|
||||
addInodeCaches k . catMaybes
|
||||
=<< liftIO (mapM (\f -> genInodeCache f d) fs)
|
||||
|
@ -265,7 +264,7 @@ reconcileStaged dbisnew qh = ifM isBareRepo
|
|||
( return mempty
|
||||
, do
|
||||
gitindex <- inRepo currentIndexFile
|
||||
indexcache <- fromRawFilePath <$> calcRepo' gitAnnexKeysDbIndexCache
|
||||
indexcache <- fromOsPath <$> calcRepo' gitAnnexKeysDbIndexCache
|
||||
withTSDelta (liftIO . genInodeCache gitindex) >>= \case
|
||||
Just cur -> readindexcache indexcache >>= \case
|
||||
Nothing -> go cur indexcache =<< getindextree
|
||||
|
@ -356,8 +355,9 @@ reconcileStaged dbisnew qh = ifM isBareRepo
|
|||
-- be a pointer file. And a pointer file that is replaced with
|
||||
-- a non-pointer file will match this. This is only a
|
||||
-- prefilter so that's ok.
|
||||
, Param $ "-G" ++ fromRawFilePath (toInternalGitPath $
|
||||
P.pathSeparator `S.cons` objectDir)
|
||||
, Param $ "-G" ++
|
||||
fromOsPath (toInternalGitPath $
|
||||
pathSeparator `OS.cons` objectDir)
|
||||
-- Disable rename detection.
|
||||
, Param "--no-renames"
|
||||
-- Avoid other complications.
|
||||
|
@ -371,6 +371,7 @@ reconcileStaged dbisnew qh = ifM isBareRepo
|
|||
procdiff mdfeeder (info:file:rest) conflicted
|
||||
| ":" `S.isPrefixOf` info = case S8.words info of
|
||||
(_colonsrcmode:dstmode:srcsha:dstsha:status:[]) -> do
|
||||
let file' = asTopFilePath (toOsPath file)
|
||||
let conflicted' = status == "U"
|
||||
-- avoid removing associated file when
|
||||
-- there is a merge conflict
|
||||
|
@ -378,17 +379,15 @@ reconcileStaged dbisnew qh = ifM isBareRepo
|
|||
send mdfeeder (Ref srcsha) $ \case
|
||||
Just oldkey -> do
|
||||
liftIO $ SQL.removeAssociatedFile oldkey
|
||||
(asTopFilePath file)
|
||||
(SQL.WriteHandle qh)
|
||||
file' (SQL.WriteHandle qh)
|
||||
return True
|
||||
Nothing -> return False
|
||||
send mdfeeder (Ref dstsha) $ \case
|
||||
Just key -> do
|
||||
liftIO $ addassociatedfile key
|
||||
(asTopFilePath file)
|
||||
(SQL.WriteHandle qh)
|
||||
file' (SQL.WriteHandle qh)
|
||||
when (dstmode /= fmtTreeItemType TreeSymlink) $
|
||||
reconcilepointerfile (asTopFilePath file) key
|
||||
reconcilepointerfile file' key
|
||||
return True
|
||||
Nothing -> return False
|
||||
procdiff mdfeeder rest
|
||||
|
@ -403,11 +402,11 @@ reconcileStaged dbisnew qh = ifM isBareRepo
|
|||
procmergeconflictdiff mdfeeder (info:file:rest) conflicted
|
||||
| ":" `S.isPrefixOf` info = case S8.words info of
|
||||
(_colonmode:_mode:sha:_sha:status:[]) -> do
|
||||
let file' = asTopFilePath (toOsPath file)
|
||||
send mdfeeder (Ref sha) $ \case
|
||||
Just key -> do
|
||||
liftIO $ SQL.addAssociatedFile key
|
||||
(asTopFilePath file)
|
||||
(SQL.WriteHandle qh)
|
||||
file' (SQL.WriteHandle qh)
|
||||
return True
|
||||
Nothing -> return False
|
||||
let conflicted' = status == "U"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue