use RawFilePath version of rename

Some small wins, almost certianly swamped by the system calls, but still
worthwhile progress on the RawFilePath conversion.

Sponsored-by: Erik Bjäreholt on Patreon
This commit is contained in:
Joey Hess 2022-06-22 16:47:34 -04:00
parent d00e23cac9
commit debcf86029
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
16 changed files with 58 additions and 54 deletions

View file

@ -28,6 +28,7 @@ import Utility.InodeCache
import Annex.InodeSentinal
import Annex.CheckIgnore
import qualified Utility.RawFilePath as R
import qualified System.FilePath.ByteString as P
import System.PosixCompat.Files
@ -208,15 +209,15 @@ start si file addunlockedmatcher =
starting "add" (ActionItemTreeFile file) si $
addingExistingLink file key $
withOtherTmp $ \tmp -> do
let tmpf = fromRawFilePath tmp </> fromRawFilePath file
liftIO $ moveFile (fromRawFilePath file) tmpf
ifM (isSymbolicLink <$> liftIO (getSymbolicLinkStatus tmpf))
let tmpf = tmp P.</> file
liftIO $ moveFile file tmpf
ifM (isSymbolicLink <$> liftIO (R.getSymbolicLinkStatus tmpf))
( do
liftIO $ removeFile tmpf
liftIO $ R.removeLink tmpf
addSymlink file key Nothing
next $ cleanup key =<< inAnnex key
, do
liftIO $ moveFile tmpf (fromRawFilePath file)
liftIO $ moveFile tmpf file
next $ return True
)
fixuppointer s key =

View file

@ -613,7 +613,7 @@ honorDead dead
badContent :: Key -> Annex String
badContent key = do
dest <- moveBad key
return $ "moved to " ++ dest
return $ "moved to " ++ fromRawFilePath dest
{- Bad content is dropped from the remote. We have downloaded a copy
- from the remote to a temp file already (in some cases, it's just a
@ -633,7 +633,7 @@ badContentRemote remote localcopy key = do
ifM (isSymbolicLink <$> R.getSymbolicLinkStatus localcopy)
( copyFileExternal CopyTimeStamps (fromRawFilePath localcopy) destbad'
, do
moveFile (fromRawFilePath localcopy) destbad'
moveFile localcopy destbad
return True
)
)

View file

@ -207,12 +207,8 @@ startLocal o addunlockedmatcher largematcher mode (srcfile, destfile) =
(fromRawFilePath destfile)
return $ removeWhenExistsWith R.removeLink destfile
else do
moveFile
(fromRawFilePath srcfile)
(fromRawFilePath destfile)
return $ moveFile
(fromRawFilePath destfile)
(fromRawFilePath srcfile)
moveFile srcfile destfile
return $ moveFile destfile srcfile
-- Make sure that the dest file has its write permissions
-- removed; the src file normally already did, but may
-- have imported it from a filesystem that does not allow

View file

@ -38,7 +38,7 @@ perform file key = do
ok <- getViaTmp RetrievalAllKeysSecure DefaultVerify key (AssociatedFile Nothing) $ \dest -> unVerified $
if dest /= file
then liftIO $ catchBoolIO $ do
moveFile (fromRawFilePath file) (fromRawFilePath dest)
moveFile file dest
return True
else return True
if ok