more RawFilePath conversion
412/645
This commit is contained in:
parent
ca80c3154c
commit
b4b02e4c61
5 changed files with 43 additions and 35 deletions
|
@ -1,6 +1,6 @@
|
||||||
{- adjusted branch
|
{- adjusted branch
|
||||||
-
|
-
|
||||||
- Copyright 2016-2018 Joey Hess <id@joeyh.name>
|
- Copyright 2016-2020 Joey Hess <id@joeyh.name>
|
||||||
-
|
-
|
||||||
- Licensed under the GNU AGPL version 3 or higher.
|
- Licensed under the GNU AGPL version 3 or higher.
|
||||||
-}
|
-}
|
||||||
|
@ -57,11 +57,13 @@ import Annex.Tmp
|
||||||
import Annex.GitOverlay
|
import Annex.GitOverlay
|
||||||
import Utility.Tmp.Dir
|
import Utility.Tmp.Dir
|
||||||
import Utility.CopyFile
|
import Utility.CopyFile
|
||||||
|
import Utility.Directory.Create
|
||||||
import qualified Database.Keys
|
import qualified Database.Keys
|
||||||
import Config
|
import Config
|
||||||
|
|
||||||
import qualified Data.Map as M
|
import qualified Data.Map as M
|
||||||
import qualified Data.ByteString as S
|
import qualified Data.ByteString as S
|
||||||
|
import qualified System.FilePath.ByteString as P
|
||||||
|
|
||||||
-- How to perform various adjustments to a TreeItem.
|
-- How to perform various adjustments to a TreeItem.
|
||||||
class AdjustTreeItem t where
|
class AdjustTreeItem t where
|
||||||
|
@ -110,11 +112,10 @@ adjustToPointer ti@(TreeItem f _m s) = catKey s >>= \case
|
||||||
adjustToSymlink :: TreeItem -> Annex (Maybe TreeItem)
|
adjustToSymlink :: TreeItem -> Annex (Maybe TreeItem)
|
||||||
adjustToSymlink = adjustToSymlink' gitAnnexLink
|
adjustToSymlink = adjustToSymlink' gitAnnexLink
|
||||||
|
|
||||||
adjustToSymlink' :: (FilePath -> Key -> Git.Repo -> GitConfig -> IO FilePath) -> TreeItem -> Annex (Maybe TreeItem)
|
adjustToSymlink' :: (RawFilePath -> Key -> Git.Repo -> GitConfig -> IO RawFilePath) -> TreeItem -> Annex (Maybe TreeItem)
|
||||||
adjustToSymlink' gitannexlink ti@(TreeItem f _m s) = catKey s >>= \case
|
adjustToSymlink' gitannexlink ti@(TreeItem f _m s) = catKey s >>= \case
|
||||||
Just k -> do
|
Just k -> do
|
||||||
absf <- inRepo $ \r -> absPath $
|
absf <- inRepo $ \r -> absPath $ fromTopFilePath f r
|
||||||
fromRawFilePath $ fromTopFilePath f r
|
|
||||||
linktarget <- calcRepo $ gitannexlink absf k
|
linktarget <- calcRepo $ gitannexlink absf k
|
||||||
Just . TreeItem f (fromTreeItemType TreeSymlink)
|
Just . TreeItem f (fromTreeItemType TreeSymlink)
|
||||||
<$> hashSymlink linktarget
|
<$> hashSymlink linktarget
|
||||||
|
@ -376,23 +377,27 @@ mergeToAdjustedBranch tomerge (origbranch, adj) mergeconfig canresolvemerge comm
|
||||||
- index file is currently locked.)
|
- index file is currently locked.)
|
||||||
-}
|
-}
|
||||||
changestomerge (Just updatedorig) = withOtherTmp $ \othertmpdir -> do
|
changestomerge (Just updatedorig) = withOtherTmp $ \othertmpdir -> do
|
||||||
git_dir <- fromRawFilePath <$> fromRepo Git.localGitDir
|
git_dir <- fromRepo Git.localGitDir
|
||||||
|
let git_dir' = fromRawFilePath git_dir
|
||||||
tmpwt <- fromRepo gitAnnexMergeDir
|
tmpwt <- fromRepo gitAnnexMergeDir
|
||||||
withTmpDirIn othertmpdir "git" $ \tmpgit -> withWorkTreeRelated tmpgit $
|
withTmpDirIn (fromRawFilePath othertmpdir) "git" $ \tmpgit -> withWorkTreeRelated tmpgit $
|
||||||
withemptydir git_dir tmpwt $ withWorkTree tmpwt $ do
|
withemptydir git_dir tmpwt $ withWorkTree tmpwt $ do
|
||||||
liftIO $ writeFile (tmpgit </> "HEAD") (fromRef updatedorig)
|
liftIO $ writeFile (tmpgit </> "HEAD") (fromRef updatedorig)
|
||||||
-- Copy in refs and packed-refs, to work
|
-- Copy in refs and packed-refs, to work
|
||||||
-- around bug in git 2.13.0, which
|
-- around bug in git 2.13.0, which
|
||||||
-- causes it not to look in GIT_DIR for refs.
|
-- causes it not to look in GIT_DIR for refs.
|
||||||
refs <- liftIO $ dirContentsRecursive $
|
refs <- liftIO $ dirContentsRecursive $
|
||||||
git_dir </> "refs"
|
git_dir' </> "refs"
|
||||||
let refs' = (git_dir </> "packed-refs") : refs
|
let refs' = (git_dir' </> "packed-refs") : refs
|
||||||
liftIO $ forM_ refs' $ \src ->
|
liftIO $ forM_ refs' $ \src ->
|
||||||
whenM (doesFileExist src) $ do
|
whenM (doesFileExist src) $ do
|
||||||
dest <- relPathDirToFile git_dir src
|
dest <- relPathDirToFile git_dir
|
||||||
let dest' = tmpgit </> dest
|
(toRawFilePath src)
|
||||||
createDirectoryUnder git_dir (takeDirectory dest')
|
let dest' = toRawFilePath tmpgit P.</> dest
|
||||||
void $ createLinkOrCopy src dest'
|
createDirectoryUnder git_dir
|
||||||
|
(P.takeDirectory dest')
|
||||||
|
void $ createLinkOrCopy src
|
||||||
|
(fromRawFilePath dest')
|
||||||
-- This reset makes git merge not care
|
-- This reset makes git merge not care
|
||||||
-- that the work tree is empty; otherwise
|
-- that the work tree is empty; otherwise
|
||||||
-- it will think that all the files have
|
-- it will think that all the files have
|
||||||
|
@ -418,7 +423,7 @@ mergeToAdjustedBranch tomerge (origbranch, adj) mergeconfig canresolvemerge comm
|
||||||
setup = do
|
setup = do
|
||||||
whenM (doesDirectoryExist d) $
|
whenM (doesDirectoryExist d) $
|
||||||
removeDirectoryRecursive d
|
removeDirectoryRecursive d
|
||||||
createDirectoryUnder git_dir d
|
createDirectoryUnder git_dir (toRawFilePath d)
|
||||||
cleanup _ = removeDirectoryRecursive d
|
cleanup _ = removeDirectoryRecursive d
|
||||||
|
|
||||||
{- A merge commit has been made between the basisbranch and
|
{- A merge commit has been made between the basisbranch and
|
||||||
|
|
|
@ -230,7 +230,7 @@ resolveMerge' unstagedmap (Just us) them inoverlay u = do
|
||||||
| otherwise = pure f
|
| otherwise = pure f
|
||||||
|
|
||||||
makesymlink key dest = do
|
makesymlink key dest = do
|
||||||
l <- calcRepo $ gitAnnexLink dest key
|
l <- calcRepo $ gitAnnexLink (toRawFilePath dest) key
|
||||||
unless inoverlay $ replacewithsymlink dest l
|
unless inoverlay $ replacewithsymlink dest l
|
||||||
dest' <- toRawFilePath <$> stagefile dest
|
dest' <- toRawFilePath <$> stagefile dest
|
||||||
stageSymlink dest' =<< hashSymlink l
|
stageSymlink dest' =<< hashSymlink l
|
||||||
|
@ -267,7 +267,7 @@ resolveMerge' unstagedmap (Just us) them inoverlay u = do
|
||||||
Nothing -> noop
|
Nothing -> noop
|
||||||
Just sha -> do
|
Just sha -> do
|
||||||
link <- catSymLinkTarget sha
|
link <- catSymLinkTarget sha
|
||||||
replacewithsymlink item (fromRawFilePath link)
|
replacewithsymlink item link
|
||||||
-- And when grafting in anything else vs a symlink,
|
-- And when grafting in anything else vs a symlink,
|
||||||
-- the work tree already contains what we want.
|
-- the work tree already contains what we want.
|
||||||
(_, Just TreeSymlink) -> noop
|
(_, Just TreeSymlink) -> noop
|
||||||
|
|
|
@ -50,6 +50,7 @@ import Upgrade
|
||||||
import Annex.Tmp
|
import Annex.Tmp
|
||||||
import Utility.UserInfo
|
import Utility.UserInfo
|
||||||
import Utility.ThreadScheduler
|
import Utility.ThreadScheduler
|
||||||
|
import qualified Utility.RawFilePath as R
|
||||||
#ifndef mingw32_HOST_OS
|
#ifndef mingw32_HOST_OS
|
||||||
import Annex.Perms
|
import Annex.Perms
|
||||||
import Utility.FileMode
|
import Utility.FileMode
|
||||||
|
@ -59,6 +60,7 @@ import Data.Either
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
import qualified Data.Map as M
|
import qualified Data.Map as M
|
||||||
|
import qualified System.FilePath.ByteString as P
|
||||||
import Control.Concurrent.Async
|
import Control.Concurrent.Async
|
||||||
|
|
||||||
checkCanInitialize :: Annex a -> Annex a
|
checkCanInitialize :: Annex a -> Annex a
|
||||||
|
@ -79,8 +81,8 @@ canInitialize' = inRepo (noAnnexFileContent . fmap fromRawFilePath . Git.repoWor
|
||||||
genDescription :: Maybe String -> Annex UUIDDesc
|
genDescription :: Maybe String -> Annex UUIDDesc
|
||||||
genDescription (Just d) = return $ UUIDDesc $ encodeBS d
|
genDescription (Just d) = return $ UUIDDesc $ encodeBS d
|
||||||
genDescription Nothing = do
|
genDescription Nothing = do
|
||||||
reldir <- liftIO . relHome
|
reldir <- liftIO . relHome . fromRawFilePath
|
||||||
=<< liftIO . absPath . fromRawFilePath
|
=<< liftIO . absPath
|
||||||
=<< fromRepo Git.repoPath
|
=<< fromRepo Git.repoPath
|
||||||
hostname <- fromMaybe "" <$> liftIO getHostname
|
hostname <- fromMaybe "" <$> liftIO getHostname
|
||||||
let at = if null hostname then "" else "@"
|
let at = if null hostname then "" else "@"
|
||||||
|
@ -194,12 +196,12 @@ probeCrippledFileSystem = withEventuallyCleanedOtherTmp $ \tmp -> do
|
||||||
mapM_ warning warnings
|
mapM_ warning warnings
|
||||||
return r
|
return r
|
||||||
|
|
||||||
probeCrippledFileSystem' :: FilePath -> IO (Bool, [String])
|
probeCrippledFileSystem' :: RawFilePath -> IO (Bool, [String])
|
||||||
#ifdef mingw32_HOST_OS
|
#ifdef mingw32_HOST_OS
|
||||||
probeCrippledFileSystem' _ = return (True, [])
|
probeCrippledFileSystem' _ = return (True, [])
|
||||||
#else
|
#else
|
||||||
probeCrippledFileSystem' tmp = do
|
probeCrippledFileSystem' tmp = do
|
||||||
let f = tmp </> "gaprobe"
|
let f = fromRawFilePath (tmp P.</> "gaprobe")
|
||||||
writeFile f ""
|
writeFile f ""
|
||||||
r <- probe f
|
r <- probe f
|
||||||
void $ tryIO $ allowWrite f
|
void $ tryIO $ allowWrite f
|
||||||
|
@ -246,18 +248,18 @@ probeLockSupport :: Annex Bool
|
||||||
probeLockSupport = return True
|
probeLockSupport = return True
|
||||||
#else
|
#else
|
||||||
probeLockSupport = withEventuallyCleanedOtherTmp $ \tmp -> do
|
probeLockSupport = withEventuallyCleanedOtherTmp $ \tmp -> do
|
||||||
let f = tmp </> "lockprobe"
|
let f = tmp P.</> "lockprobe"
|
||||||
mode <- annexFileMode
|
mode <- annexFileMode
|
||||||
liftIO $ withAsync warnstall (const (go f mode))
|
liftIO $ withAsync warnstall (const (go f mode))
|
||||||
where
|
where
|
||||||
go f mode = do
|
go f mode = do
|
||||||
removeWhenExistsWith removeLink f
|
removeWhenExistsWith R.removeLink f
|
||||||
let locktest = bracket
|
let locktest = bracket
|
||||||
(Posix.lockExclusive (Just mode) f)
|
(Posix.lockExclusive (Just mode) f)
|
||||||
Posix.dropLock
|
Posix.dropLock
|
||||||
(const noop)
|
(const noop)
|
||||||
ok <- isRight <$> tryNonAsync locktest
|
ok <- isRight <$> tryNonAsync locktest
|
||||||
removeWhenExistsWith removeLink f
|
removeWhenExistsWith R.removeLink f
|
||||||
return ok
|
return ok
|
||||||
|
|
||||||
warnstall = do
|
warnstall = do
|
||||||
|
@ -272,17 +274,17 @@ probeFifoSupport = do
|
||||||
return False
|
return False
|
||||||
#else
|
#else
|
||||||
withEventuallyCleanedOtherTmp $ \tmp -> do
|
withEventuallyCleanedOtherTmp $ \tmp -> do
|
||||||
let f = tmp </> "gaprobe"
|
let f = tmp P.</> "gaprobe"
|
||||||
let f2 = tmp </> "gaprobe2"
|
let f2 = tmp P.</> "gaprobe2"
|
||||||
liftIO $ do
|
liftIO $ do
|
||||||
removeWhenExistsWith removeLink f
|
removeWhenExistsWith R.removeLink f
|
||||||
removeWhenExistsWith removeLink f2
|
removeWhenExistsWith R.removeLink f2
|
||||||
ms <- tryIO $ do
|
ms <- tryIO $ do
|
||||||
createNamedPipe f ownerReadMode
|
createNamedPipe (fromRawFilePath f) ownerReadMode
|
||||||
createLink f f2
|
R.createLink f f2
|
||||||
getFileStatus f
|
R.getFileStatus f
|
||||||
removeWhenExistsWith removeLink f
|
removeWhenExistsWith R.removeLink f
|
||||||
removeWhenExistsWith removeLink f2
|
removeWhenExistsWith R.removeLink f2
|
||||||
return $ either (const False) isNamedPipe ms
|
return $ either (const False) isNamedPipe ms
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -51,9 +51,9 @@ needsUpgrade v
|
||||||
where
|
where
|
||||||
err msg = do
|
err msg = do
|
||||||
g <- Annex.gitRepo
|
g <- Annex.gitRepo
|
||||||
p <- liftIO $ absPath $ fromRawFilePath $ Git.repoPath g
|
p <- liftIO $ absPath $ Git.repoPath g
|
||||||
return $ Just $ unwords
|
return $ Just $ unwords
|
||||||
[ "Repository", p
|
[ "Repository", fromRawFilePath p
|
||||||
, "is at unsupported version"
|
, "is at unsupported version"
|
||||||
, show (fromRepoVersion v) ++ "."
|
, show (fromRepoVersion v) ++ "."
|
||||||
, msg
|
, msg
|
||||||
|
|
|
@ -132,13 +132,14 @@ upgradeDirectWorkTree = do
|
||||||
|
|
||||||
fromdirect f k = ifM (Direct.goodContent k f)
|
fromdirect f k = ifM (Direct.goodContent k f)
|
||||||
( do
|
( do
|
||||||
|
let f' = toRawFilePath f
|
||||||
-- If linkToAnnex fails for some reason, the work tree
|
-- If linkToAnnex fails for some reason, the work tree
|
||||||
-- file still has the content; the annex object file
|
-- file still has the content; the annex object file
|
||||||
-- is just not populated with it. Since the work tree
|
-- is just not populated with it. Since the work tree
|
||||||
-- file is recorded as an associated file, things will
|
-- file is recorded as an associated file, things will
|
||||||
-- still work that way, it's just not ideal.
|
-- still work that way, it's just not ideal.
|
||||||
ic <- withTSDelta (liftIO . genInodeCache (toRawFilePath f))
|
ic <- withTSDelta (liftIO . genInodeCache f')
|
||||||
void $ Content.linkToAnnex k f ic
|
void $ Content.linkToAnnex k f' ic
|
||||||
, unlessM (Content.inAnnex k) $ do
|
, unlessM (Content.inAnnex k) $ do
|
||||||
-- Worktree file was deleted or modified;
|
-- Worktree file was deleted or modified;
|
||||||
-- if there are no other copies of the content
|
-- if there are no other copies of the content
|
||||||
|
|
Loading…
Add table
Reference in a new issue