more RawFilePath conversion

at 377/645

This commit was sponsored by Svenne Krap on Patreon.
This commit is contained in:
Joey Hess 2020-10-29 14:20:57 -04:00
parent f45ad178cb
commit 681b44236a
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
23 changed files with 215 additions and 188 deletions

View file

@ -18,7 +18,8 @@ upgrade = do
-- do the reorganisation of the key files
olddir <- fromRawFilePath <$> fromRepo gitAnnexDir
keys <- getKeysPresent0 olddir
forM_ keys $ \k -> moveAnnex k $ olddir </> keyFile0 k
forM_ keys $ \k ->
moveAnnex k $ toRawFilePath $ olddir </> keyFile0 k
-- update the symlinks to the key files
-- No longer needed here; V1.upgrade does the same thing

View file

@ -75,10 +75,10 @@ moveContent = do
where
move f = do
let k = fileKey1 (takeFileName f)
let d = parentDir f
let d = fromRawFilePath $ parentDir $ toRawFilePath f
liftIO $ allowWrite d
liftIO $ allowWrite f
_ <- moveAnnex k f
_ <- moveAnnex k (toRawFilePath f)
liftIO $ removeDirectory d
updateSymlinks :: Annex ()
@ -94,7 +94,8 @@ updateSymlinks = do
case r of
Nothing -> noop
Just (k, _) -> do
link <- calcRepo $ gitAnnexLink f k
link <- fromRawFilePath
<$> calcRepo (gitAnnexLink (toRawFilePath f) k)
liftIO $ removeFile f
liftIO $ createSymbolicLink link f
Annex.Queue.addCommand "add" [Param "--"] [f]
@ -113,10 +114,10 @@ moveLocationLogs = do
, return []
)
move (l, k) = do
dest <- fromRepo $ logFile2 k
dest <- fromRepo (logFile2 k)
dir <- fromRepo Upgrade.V2.gitStateDir
let f = dir </> l
createWorkTreeDirectory (parentDir dest)
createWorkTreeDirectory (parentDir (toRawFilePath dest))
-- could just git mv, but this way deals with
-- log files that are not checked into git,
-- as well as merging with already upgraded

View file

@ -132,7 +132,7 @@ attrLines =
gitAttributesUnWrite :: Git.Repo -> IO ()
gitAttributesUnWrite repo = do
let attributes = Git.attributes repo
let attributes = fromRawFilePath (Git.attributes repo)
whenM (doesFileExist attributes) $ do
c <- readFileStrict attributes
liftIO $ viaTmp writeFile attributes $ unlines $

View file

@ -5,6 +5,7 @@
- Licensed under the GNU AGPL version 3 or higher.
-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE CPP #-}
module Upgrade.V7 where
@ -18,6 +19,9 @@ import qualified Git.LsFiles as LsFiles
import qualified Git
import Git.FilePath
import Config
import qualified Utility.RawFilePath as R
import qualified System.FilePath.ByteString as P
upgrade :: Bool -> Annex Bool
upgrade automatic = do
@ -33,7 +37,7 @@ upgrade automatic = do
-- new database is not populated. It will be automatically
-- populated from the git-annex branch the next time it is used.
removeOldDb gitAnnexContentIdentifierDbDirOld
liftIO . removeWhenExistsWith removeLink
liftIO . removeWhenExistsWith R.removeLink
=<< fromRepo gitAnnexContentIdentifierLockOld
-- The export databases are deleted here. The new databases
@ -43,33 +47,33 @@ upgrade automatic = do
populateKeysDb
removeOldDb gitAnnexKeysDbOld
liftIO . removeWhenExistsWith removeLink
liftIO . removeWhenExistsWith R.removeLink
=<< fromRepo gitAnnexKeysDbIndexCacheOld
liftIO . removeWhenExistsWith removeLink
liftIO . removeWhenExistsWith R.removeLink
=<< fromRepo gitAnnexKeysDbLockOld
updateSmudgeFilter
return True
gitAnnexKeysDbOld :: Git.Repo -> FilePath
gitAnnexKeysDbOld r = fromRawFilePath (gitAnnexDir r) </> "keys"
gitAnnexKeysDbOld :: Git.Repo -> RawFilePath
gitAnnexKeysDbOld r = gitAnnexDir r P.</> "keys"
gitAnnexKeysDbLockOld :: Git.Repo -> FilePath
gitAnnexKeysDbLockOld r = gitAnnexKeysDbOld r ++ ".lck"
gitAnnexKeysDbLockOld :: Git.Repo -> RawFilePath
gitAnnexKeysDbLockOld r = gitAnnexKeysDbOld r <> ".lck"
gitAnnexKeysDbIndexCacheOld :: Git.Repo -> FilePath
gitAnnexKeysDbIndexCacheOld r = gitAnnexKeysDbOld r ++ ".cache"
gitAnnexKeysDbIndexCacheOld :: Git.Repo -> RawFilePath
gitAnnexKeysDbIndexCacheOld r = gitAnnexKeysDbOld r <> ".cache"
gitAnnexContentIdentifierDbDirOld :: Git.Repo -> FilePath
gitAnnexContentIdentifierDbDirOld r = fromRawFilePath (gitAnnexDir r) </> "cids"
gitAnnexContentIdentifierDbDirOld :: Git.Repo -> RawFilePath
gitAnnexContentIdentifierDbDirOld r = gitAnnexDir r P.</> "cids"
gitAnnexContentIdentifierLockOld :: Git.Repo -> FilePath
gitAnnexContentIdentifierLockOld r = gitAnnexContentIdentifierDbDirOld r ++ ".lck"
gitAnnexContentIdentifierLockOld :: Git.Repo -> RawFilePath
gitAnnexContentIdentifierLockOld r = gitAnnexContentIdentifierDbDirOld r <> ".lck"
removeOldDb :: (Git.Repo -> FilePath) -> Annex ()
removeOldDb :: (Git.Repo -> RawFilePath) -> Annex ()
removeOldDb getdb = do
db <- fromRepo getdb
db <- fromRawFilePath <$> fromRepo getdb
whenM (liftIO $ doesDirectoryExist db) $ do
v <- liftIO $ tryNonAsync $
#if MIN_VERSION_directory(1,2,7)
@ -124,7 +128,7 @@ populateKeysDb = unlessM isBareRepo $ do
-- checked into the repository.
updateSmudgeFilter :: Annex ()
updateSmudgeFilter = do
lf <- Annex.fromRepo Git.attributesLocal
lf <- fromRawFilePath <$> Annex.fromRepo Git.attributesLocal
ls <- liftIO $ lines <$> catchDefaultIO "" (readFileStrict lf)
let ls' = removedotfilter ls
when (ls /= ls') $