summaryrefslogtreecommitdiff
path: root/Annex/CatFile.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2014-08-20 12:01:45 -0400
committerGravatar Joey Hess <joey@kitenet.net>2014-08-20 12:07:57 -0400
commit60688bf3956d6a905f55fb61e6a59f0e075e70ba (patch)
treefc2fd5fdbd53c7d459b09d6beb8507b24c71a2cf /Annex/CatFile.hs
parent07505caecbf5ef89050fc701c41fea92ac569e77 (diff)
When accessing a local remote, shut down git-cat-file processes afterwards, to ensure that remotes on removable media can be unmounted. Closes: #758630
This does mean that eg, copying multiple files to a local remote will become slightly slower, since it now restarts git-cat-file after each copy. Should not be significant slowdown. The reason git-cat-file is run on the remote at all is to update its location log. In order to add an item to it, it needs to get the current content of the log. Finding a way to avoid needing to do that would be a good path to avoiding this slowdown if it does become a problem somehow. This commit was sponsored by Evan Deaubl.
Diffstat (limited to 'Annex/CatFile.hs')
-rw-r--r--Annex/CatFile.hs9
1 files changed, 9 insertions, 0 deletions
diff --git a/Annex/CatFile.hs b/Annex/CatFile.hs
index 2f8c43079..8b4d746e1 100644
--- a/Annex/CatFile.hs
+++ b/Annex/CatFile.hs
@@ -12,6 +12,7 @@ module Annex.CatFile (
catTree,
catObjectDetails,
catFileHandle,
+ catFileStop,
catKey,
catKeyFile,
catKeyFileHEAD,
@@ -71,6 +72,14 @@ catFileHandle = do
Annex.changeState $ \s -> s { Annex.catfilehandles = m' }
return h
+{- Stops all running cat-files. Should only be run when it's known that
+ - nothing is using the handles, eg at shutdown. -}
+catFileStop :: Annex ()
+catFileStop = do
+ m <- Annex.withState $ \s ->
+ (s { Annex.catfilehandles = M.empty }, Annex.catfilehandles s)
+ liftIO $ mapM_ Git.CatFile.catFileStop (M.elems m)
+
{- From the Sha or Ref of a symlink back to the key.
-
- Requires a mode witness, to guarantee that the file is a symlink.