more OsPath conversion (602/749)

Sponsored-by: Brock Spratlen
This commit is contained in:
Joey Hess 2025-02-07 14:46:11 -04:00
parent 2d1db7986c
commit a5d48edd94
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
25 changed files with 227 additions and 187 deletions

View file

@ -39,7 +39,7 @@ seek ps = withFilesInGitAnnex ww seeker =<< workTreeItems ww ps
, usesLocationLog = False
}
start :: SeekInput -> RawFilePath -> Key -> CommandStart
start :: SeekInput -> OsPath -> Key -> CommandStart
start si file key = ifM (isJust <$> isAnnexLink file)
( stop
, starting "lock" (mkActionItem (key, file)) si $
@ -59,7 +59,7 @@ start si file key = ifM (isJust <$> isAnnexLink file)
)
cont = perform file key
perform :: RawFilePath -> Key -> CommandPerform
perform :: OsPath -> Key -> CommandPerform
perform file key = do
lockdown =<< calcRepo (gitAnnexLocation key)
addSymlink file key =<< withTSDelta (liftIO . genInodeCache file)
@ -70,12 +70,14 @@ perform file key = do
( breakhardlink obj
, repopulate obj
)
whenM (liftIO $ R.doesPathExist obj) $
whenM (liftIO $ doesFileExist obj) $
freezeContent obj
getlinkcount obj = linkCount <$> liftIO (R.getFileStatus (fromOsPath obj))
-- It's ok if the file is hard linked to obj, but if some other
-- associated file is, we need to break that link to lock down obj.
breakhardlink obj = whenM (catchBoolIO $ (> 1) . linkCount <$> liftIO (R.getFileStatus obj)) $ do
breakhardlink obj = whenM (catchBoolIO $ (> 1) <$> getlinkcount obj) $ do
mfc <- withTSDelta (liftIO . genInodeCache file)
unlessM (sameInodeCache obj (maybeToList mfc)) $ do
modifyContentDir obj $ replaceGitAnnexDirFile obj $ \tmp -> do
@ -89,7 +91,7 @@ perform file key = do
fs <- map (`fromTopFilePath` g)
<$> Database.Keys.getAssociatedFiles key
mfile <- firstM (isUnmodified key) fs
liftIO $ removeWhenExistsWith R.removeLink obj
liftIO $ removeWhenExistsWith removeFile obj
case mfile of
Just unmodified ->
ifM (checkedCopyFile key unmodified obj Nothing)