replace removeLink with removeFile
same reasoning as in commit 5cc8d9d03b
This commit is contained in:
parent
90eb1e2da6
commit
f8bb9a8734
9 changed files with 16 additions and 21 deletions
|
@ -34,10 +34,9 @@ populatePointerFile :: Restage -> Key -> OsPath -> OsPath -> Annex (Maybe InodeC
|
|||
populatePointerFile restage k obj f = go =<< liftIO (isPointerFile f)
|
||||
where
|
||||
go (Just k') | k == k' = do
|
||||
let f' = fromOsPath f
|
||||
destmode <- liftIO $ catchMaybeIO $
|
||||
fileMode <$> R.getFileStatus f'
|
||||
liftIO $ removeWhenExistsWith R.removeLink f'
|
||||
fileMode <$> R.getFileStatus (fromOsPath f)
|
||||
liftIO $ removeWhenExistsWith removeFile f
|
||||
(ic, populated) <- replaceWorkTreeFile f $ \tmp -> do
|
||||
ok <- linkOrCopy k obj tmp destmode >>= \case
|
||||
Just _ -> thawContent tmp >> return True
|
||||
|
@ -55,11 +54,10 @@ populatePointerFile restage k obj f = go =<< liftIO (isPointerFile f)
|
|||
- Does not check if the pointer file is modified. -}
|
||||
depopulatePointerFile :: Key -> OsPath -> Annex ()
|
||||
depopulatePointerFile key file = do
|
||||
let file' = fromOsPath file
|
||||
st <- liftIO $ catchMaybeIO $ R.getFileStatus file'
|
||||
st <- liftIO $ catchMaybeIO $ R.getFileStatus (fromOsPath file)
|
||||
let mode = fmap fileMode st
|
||||
secureErase file
|
||||
liftIO $ removeWhenExistsWith R.removeLink file'
|
||||
liftIO $ removeWhenExistsWith removeFile file
|
||||
ic <- replaceWorkTreeFile file $ \tmp -> do
|
||||
liftIO $ writePointerFile tmp key mode
|
||||
#if ! defined(mingw32_HOST_OS)
|
||||
|
|
|
@ -116,7 +116,7 @@ inAnnexSafe key = inAnnex' (fromMaybe True) (Just False) go key
|
|||
Nothing -> return is_locked
|
||||
Just lockhandle -> do
|
||||
dropLock lockhandle
|
||||
void $ tryIO $ removeWhenExistsWith R.removeLink lockfile
|
||||
void $ tryIO $ removeWhenExistsWith removeFile lockfile
|
||||
return is_unlocked
|
||||
, return is_missing
|
||||
)
|
||||
|
|
|
@ -112,9 +112,8 @@ fixupUnusualRepos r@(Repo { location = l@(Local { worktree = Just w, gitdir = d
|
|||
|
||||
replacedotgit = whenM (doesFileExist dotgit) $ do
|
||||
linktarget <- relPathDirToFile w d
|
||||
let dotgit' = fromOsPath dotgit
|
||||
removeWhenExistsWith R.removeLink dotgit'
|
||||
R.createSymbolicLink (fromOsPath linktarget) dotgit'
|
||||
removeWhenExistsWith removeFile dotgit
|
||||
R.createSymbolicLink (fromOsPath linktarget) (fromOsPath dotgit)
|
||||
|
||||
-- Unsetting a config fails if it's not set, so ignore failure.
|
||||
unsetcoreworktree = void $ Git.Config.unset "core.worktree" r
|
||||
|
|
|
@ -120,7 +120,7 @@ lockDown' cfg file = tryNonAsync $ ifM crippledFileSystem
|
|||
relatedTemplate $ fromOsPath $
|
||||
literalOsPath "ingest-" <> takeFileName file
|
||||
hClose h
|
||||
removeWhenExistsWith R.removeLink (fromOsPath tmpfile)
|
||||
removeWhenExistsWith removeFile tmpfile
|
||||
withhardlink' delta tmpfile
|
||||
`catchIO` const (nohardlink' delta)
|
||||
|
||||
|
|
|
@ -116,12 +116,10 @@ makeAnnexLink = makeGitLink
|
|||
makeGitLink :: LinkTarget -> OsPath -> Annex ()
|
||||
makeGitLink linktarget file = ifM (coreSymlinks <$> Annex.getGitConfig)
|
||||
( liftIO $ do
|
||||
void $ tryIO $ R.removeLink file'
|
||||
R.createSymbolicLink linktarget file'
|
||||
void $ tryIO $ removeFile file
|
||||
R.createSymbolicLink linktarget (fromOsPath file)
|
||||
, liftIO $ F.writeFile' file linktarget
|
||||
)
|
||||
where
|
||||
file' = fromOsPath file
|
||||
|
||||
{- Creates a link on disk, and additionally stages it in git. -}
|
||||
addAnnexLink :: LinkTarget -> OsPath -> Annex ()
|
||||
|
|
|
@ -61,7 +61,7 @@ cleanupOtherTmp = do
|
|||
tmpdir <- fromRepo gitAnnexTmpOtherDir
|
||||
void $ liftIO $ tryIO $ removeDirectoryRecursive tmpdir
|
||||
oldtmp <- fromRepo gitAnnexTmpOtherDirOld
|
||||
liftIO $ mapM_ (cleanold . fromOsPath)
|
||||
liftIO $ mapM_ cleanold
|
||||
=<< emptyWhenDoesNotExist (dirContentsRecursive oldtmp)
|
||||
-- remove when empty
|
||||
liftIO $ void $ tryIO $ removeDirectory oldtmp
|
||||
|
@ -69,7 +69,7 @@ cleanupOtherTmp = do
|
|||
cleanold f = do
|
||||
now <- liftIO getPOSIXTime
|
||||
let oldenough = now - (60 * 60 * 24 * 7)
|
||||
catchMaybeIO (modificationTime <$> R.getSymbolicLinkStatus f) >>= \case
|
||||
catchMaybeIO (modificationTime <$> R.getSymbolicLinkStatus (fromOsPath f)) >>= \case
|
||||
Just mtime | realToFrac mtime <= oldenough ->
|
||||
void $ tryIO $ removeWhenExistsWith R.removeLink f
|
||||
void $ tryIO $ removeWhenExistsWith removeFile f
|
||||
_ -> return ()
|
||||
|
|
|
@ -216,7 +216,7 @@ runTransfer' ignorelock t eventualbackend afile stalldetection retrydecider tran
|
|||
-}
|
||||
maybe noop dropLock moldlockhandle
|
||||
dropLock lockhandle
|
||||
void $ tryIO $ R.removeLink lckfile
|
||||
void $ tryIO $ removeFile lckfile
|
||||
maybe noop (void . tryIO . removeFile) moldlckfile
|
||||
#endif
|
||||
|
||||
|
|
|
@ -233,7 +233,7 @@ buildrpms topdir l = do
|
|||
<$> liftIO (getDirectoryContents rpmrepo)
|
||||
forM_ tarrpmarches $ \(tararch, rpmarch) ->
|
||||
forM_ (filter (isstandalonetarball tararch . fst) l) $ \(tarball, v) -> do
|
||||
liftIO $ mapM_ (removeWhenExistsWith (R.removeLink . toRawFilePath))
|
||||
liftIO $ mapM_ (removeWhenExistsWith removeFile)
|
||||
(filter ((rpmarch ++ ".rpm") `isSuffixOf`) oldrpms)
|
||||
void $ liftIO $ boolSystem script
|
||||
[ Param rpmarch
|
||||
|
|
|
@ -246,7 +246,7 @@ fixLink key file = do
|
|||
| want /= fromInternalGitPath have = do
|
||||
showNote "fixing link"
|
||||
createWorkTreeDirectory (parentDir file)
|
||||
liftIO $ R.removeLink (fromOsPath file)
|
||||
liftIO $ removeFile file
|
||||
addAnnexLink (fromOsPath want) file
|
||||
| otherwise = noop
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue