use a different tmp file when fscking remote data
Since the content might be symlinked into place, it's not appropriate to use withTmp here.
This commit is contained in:
parent
71cb04bb6d
commit
f35a84fac7
1 changed files with 10 additions and 2 deletions
|
@ -58,13 +58,13 @@ perform key file backend numcopies = check
|
||||||
{- To fsck a remote, the content is retrieved to a tmp file,
|
{- To fsck a remote, the content is retrieved to a tmp file,
|
||||||
- and checked locally. -}
|
- and checked locally. -}
|
||||||
performRemote :: Key -> FilePath -> Backend -> Maybe Int -> Remote -> CommandPerform
|
performRemote :: Key -> FilePath -> Backend -> Maybe Int -> Remote -> CommandPerform
|
||||||
performRemote key file backend numcopies remote = withTmp key $ \tmpfile -> do
|
performRemote key file backend numcopies remote = do
|
||||||
v <- Remote.hasKey remote key
|
v <- Remote.hasKey remote key
|
||||||
case v of
|
case v of
|
||||||
Left err -> do
|
Left err -> do
|
||||||
showNote err
|
showNote err
|
||||||
stop
|
stop
|
||||||
Right True -> do
|
Right True -> withtmp $ \tmpfile -> do
|
||||||
copied <- Remote.retrieveKeyFile remote key True tmpfile
|
copied <- Remote.retrieveKeyFile remote key True tmpfile
|
||||||
if copied then go True (Just tmpfile) else go False Nothing
|
if copied then go True (Just tmpfile) else go False Nothing
|
||||||
Right False -> go False Nothing
|
Right False -> go False Nothing
|
||||||
|
@ -75,6 +75,14 @@ performRemote key file backend numcopies remote = withTmp key $ \tmpfile -> do
|
||||||
, checkBackendRemote backend key remote localcopy
|
, checkBackendRemote backend key remote localcopy
|
||||||
, checkKeyNumCopies key file numcopies
|
, checkKeyNumCopies key file numcopies
|
||||||
]
|
]
|
||||||
|
withtmp a = do
|
||||||
|
pid <- liftIO getProcessID
|
||||||
|
t <- fromRepo gitAnnexTmpDir
|
||||||
|
let tmp = t </> "fsck" ++ show pid ++ "." ++ keyFile key
|
||||||
|
liftIO $ createDirectoryIfMissing True t
|
||||||
|
let cleanup = liftIO $ catch (removeFile tmp) (const $ return ())
|
||||||
|
cleanup
|
||||||
|
cleanup `after` a tmp
|
||||||
|
|
||||||
{- To fsck a bare repository, fsck each key in the location log. -}
|
{- To fsck a bare repository, fsck each key in the location log. -}
|
||||||
withBarePresentKeys :: (Key -> CommandStart) -> CommandSeek
|
withBarePresentKeys :: (Key -> CommandStart) -> CommandSeek
|
||||||
|
|
Loading…
Reference in a new issue