push RawFilePath down into Annex.ReplaceFile
Minor optimisation, but a win in every case, except for a couple where it's a wash. Note that replaceFile still takes a FilePath, because it needs to operate on Chars to truncate unicode filenames properly.
This commit is contained in:
parent
c873586e14
commit
d9fd205cbb
12 changed files with 38 additions and 44 deletions
|
@ -73,12 +73,11 @@ start fixwhat si file key = do
|
|||
breakHardLink :: RawFilePath -> Key -> RawFilePath -> CommandPerform
|
||||
breakHardLink file key obj = do
|
||||
replaceWorkTreeFile (fromRawFilePath file) $ \tmp -> do
|
||||
let tmp' = toRawFilePath tmp
|
||||
mode <- liftIO $ catchMaybeIO $ fileMode <$> R.getFileStatus file
|
||||
unlessM (checkedCopyFile key obj tmp' mode) $
|
||||
unlessM (checkedCopyFile key obj tmp mode) $
|
||||
giveup "unable to break hard link"
|
||||
thawContent tmp'
|
||||
Database.Keys.storeInodeCaches key [tmp']
|
||||
thawContent tmp
|
||||
Database.Keys.storeInodeCaches key [tmp]
|
||||
modifyContentDir obj $ freezeContent obj
|
||||
next $ return True
|
||||
|
||||
|
@ -86,7 +85,7 @@ makeHardLink :: RawFilePath -> Key -> CommandPerform
|
|||
makeHardLink file key = do
|
||||
replaceWorkTreeFile (fromRawFilePath file) $ \tmp -> do
|
||||
mode <- liftIO $ catchMaybeIO $ fileMode <$> R.getFileStatus file
|
||||
linkFromAnnex' key (toRawFilePath tmp) mode >>= \case
|
||||
linkFromAnnex' key tmp mode >>= \case
|
||||
LinkAnnexFailed -> giveup "unable to make hard link"
|
||||
_ -> noop
|
||||
next $ return True
|
||||
|
@ -99,10 +98,9 @@ fixSymlink file link = do
|
|||
<$> R.getSymbolicLinkStatus file
|
||||
#endif
|
||||
replaceWorkTreeFile (fromRawFilePath file) $ \tmpfile -> do
|
||||
let tmpfile' = toRawFilePath tmpfile
|
||||
liftIO $ R.createSymbolicLink link tmpfile'
|
||||
liftIO $ R.createSymbolicLink link tmpfile
|
||||
#if ! defined(mingw32_HOST_OS)
|
||||
liftIO $ maybe noop (\t -> touch tmpfile' t False) mtime
|
||||
liftIO $ maybe noop (\t -> touch tmpfile t False) mtime
|
||||
#endif
|
||||
stageSymlink file =<< hashSymlink link
|
||||
next $ return True
|
||||
|
|
|
@ -417,16 +417,15 @@ verifyWorkTree key file = do
|
|||
Just k | k == key -> whenM (inAnnex key) $ do
|
||||
showNote "fixing worktree content"
|
||||
replaceWorkTreeFile (fromRawFilePath file) $ \tmp -> do
|
||||
let tmp' = toRawFilePath tmp
|
||||
mode <- liftIO $ catchMaybeIO $ fileMode <$> R.getFileStatus file
|
||||
ifM (annexThin <$> Annex.getGitConfig)
|
||||
( void $ linkFromAnnex' key tmp' mode
|
||||
( void $ linkFromAnnex' key tmp mode
|
||||
, do
|
||||
obj <- calcRepo (gitAnnexLocation key)
|
||||
void $ checkedCopyFile key obj tmp' mode
|
||||
thawContent tmp'
|
||||
void $ checkedCopyFile key obj tmp mode
|
||||
thawContent tmp
|
||||
)
|
||||
Database.Keys.storeInodeCaches key [tmp']
|
||||
Database.Keys.storeInodeCaches key [tmp]
|
||||
_ -> return ()
|
||||
return True
|
||||
|
||||
|
|
|
@ -79,7 +79,7 @@ perform file key = do
|
|||
mfc <- withTSDelta (liftIO . genInodeCache file)
|
||||
unlessM (sameInodeCache obj (maybeToList mfc)) $ do
|
||||
modifyContentDir obj $ replaceGitAnnexDirFile (fromRawFilePath obj) $ \tmp -> do
|
||||
unlessM (checkedCopyFile key obj (toRawFilePath tmp) Nothing) $
|
||||
unlessM (checkedCopyFile key obj tmp Nothing) $
|
||||
giveup "unable to lock file"
|
||||
Database.Keys.storeInodeCaches key [obj]
|
||||
|
||||
|
|
|
@ -111,10 +111,9 @@ linkKey file oldkey newkey = ifM (isJust <$> isAnnexLink file)
|
|||
when (linkCount st > 1) $ do
|
||||
freezeContent oldobj
|
||||
replaceWorkTreeFile (fromRawFilePath file) $ \tmp -> do
|
||||
let tmp' = toRawFilePath tmp
|
||||
unlessM (checkedCopyFile oldkey oldobj tmp' Nothing) $
|
||||
unlessM (checkedCopyFile oldkey oldobj tmp Nothing) $
|
||||
giveup "can't lock old key"
|
||||
thawContent tmp'
|
||||
thawContent tmp
|
||||
ic <- withTSDelta (liftIO . genInodeCache file)
|
||||
case v of
|
||||
Left e -> do
|
||||
|
|
|
@ -54,14 +54,14 @@ perform dest key = do
|
|||
destic <- replaceWorkTreeFile (fromRawFilePath dest) $ \tmp -> do
|
||||
ifM (inAnnex key)
|
||||
( do
|
||||
r <- linkFromAnnex' key (toRawFilePath tmp) destmode
|
||||
r <- linkFromAnnex' key tmp destmode
|
||||
case r of
|
||||
LinkAnnexOk -> return ()
|
||||
LinkAnnexNoop -> return ()
|
||||
LinkAnnexFailed -> giveup "unlock failed"
|
||||
, liftIO $ writePointerFile (toRawFilePath tmp) key destmode
|
||||
, liftIO $ writePointerFile tmp key destmode
|
||||
)
|
||||
withTSDelta (liftIO . genInodeCache (toRawFilePath tmp))
|
||||
withTSDelta (liftIO . genInodeCache tmp)
|
||||
next $ cleanup dest destic key destmode
|
||||
|
||||
cleanup :: RawFilePath -> Maybe InodeCache -> Key -> Maybe FileMode -> CommandCleanup
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue