avoid sometimes expensive operations when annex.supportunlocked = false
This will mostly just avoid a DB lookup, so things get marginally faster. But in cases where there are many files using the same key, it can be a more significant speedup. Added overhead is one MVar lookup per call, which should be small enough, since this happens after transferring or ingesting a file, which is always a lot more work than that. It would be nice, though, to move getGitConfig to AnnexRead, which there is an open todo about.
This commit is contained in:
parent
a02b5c2904
commit
014dc63a55
4 changed files with 35 additions and 23 deletions
|
@ -340,12 +340,13 @@ moveAnnex key af src = ifM (checkSecureHashes' key)
|
||||||
liftIO $ moveFile
|
liftIO $ moveFile
|
||||||
(fromRawFilePath src)
|
(fromRawFilePath src)
|
||||||
(fromRawFilePath dest)
|
(fromRawFilePath dest)
|
||||||
g <- Annex.gitRepo
|
whenM (annexSupportUnlocked <$> Annex.getGitConfig) $ do
|
||||||
fs <- map (`fromTopFilePath` g)
|
g <- Annex.gitRepo
|
||||||
<$> Database.Keys.getAssociatedFiles key
|
fs <- map (`fromTopFilePath` g)
|
||||||
unless (null fs) $ do
|
<$> Database.Keys.getAssociatedFiles key
|
||||||
ics <- mapM (populatePointerFile (Restage True) key dest) fs
|
unless (null fs) $ do
|
||||||
Database.Keys.storeInodeCaches' key [dest] (catMaybes ics)
|
ics <- mapM (populatePointerFile (Restage True) key dest) fs
|
||||||
|
Database.Keys.storeInodeCaches' key [dest] (catMaybes ics)
|
||||||
)
|
)
|
||||||
alreadyhave = liftIO $ R.removeLink src
|
alreadyhave = liftIO $ R.removeLink src
|
||||||
|
|
||||||
|
@ -502,10 +503,11 @@ removeAnnex (ContentRemovalLock key) = withObjectLoc key $ \file ->
|
||||||
cleanObjectLoc key $ do
|
cleanObjectLoc key $ do
|
||||||
secureErase file
|
secureErase file
|
||||||
liftIO $ removeWhenExistsWith R.removeLink file
|
liftIO $ removeWhenExistsWith R.removeLink file
|
||||||
g <- Annex.gitRepo
|
whenM (annexSupportUnlocked <$> Annex.getGitConfig) $ do
|
||||||
mapM_ (\f -> void $ tryIO $ resetpointer $ fromTopFilePath f g)
|
g <- Annex.gitRepo
|
||||||
=<< Database.Keys.getAssociatedFiles key
|
mapM_ (\f -> void $ tryIO $ resetpointer $ fromTopFilePath f g)
|
||||||
Database.Keys.removeInodeCaches key
|
=<< Database.Keys.getAssociatedFiles key
|
||||||
|
Database.Keys.removeInodeCaches key
|
||||||
where
|
where
|
||||||
-- Check associated pointer file for modifications, and reset if
|
-- Check associated pointer file for modifications, and reset if
|
||||||
-- it's unmodified.
|
-- it's unmodified.
|
||||||
|
|
|
@ -225,14 +225,15 @@ finishIngestUnlocked' key source restage = do
|
||||||
|
|
||||||
{- Copy to any unlocked files using the same key. -}
|
{- Copy to any unlocked files using the same key. -}
|
||||||
populateUnlockedFiles :: Key -> KeySource -> Restage -> Annex ()
|
populateUnlockedFiles :: Key -> KeySource -> Restage -> Annex ()
|
||||||
populateUnlockedFiles key source restage = do
|
populateUnlockedFiles key source restage =
|
||||||
obj <- calcRepo (gitAnnexLocation key)
|
whenM (annexSupportUnlocked <$> Annex.getGitConfig) $ do
|
||||||
g <- Annex.gitRepo
|
obj <- calcRepo (gitAnnexLocation key)
|
||||||
ingestedf <- flip fromTopFilePath g
|
g <- Annex.gitRepo
|
||||||
<$> inRepo (toTopFilePath (keyFilename source))
|
ingestedf <- flip fromTopFilePath g
|
||||||
afs <- map (`fromTopFilePath` g) <$> Database.Keys.getAssociatedFiles key
|
<$> inRepo (toTopFilePath (keyFilename source))
|
||||||
forM_ (filter (/= ingestedf) afs) $
|
afs <- map (`fromTopFilePath` g) <$> Database.Keys.getAssociatedFiles key
|
||||||
populatePointerFile restage key obj
|
forM_ (filter (/= ingestedf) afs) $
|
||||||
|
populatePointerFile restage key obj
|
||||||
|
|
||||||
cleanCruft :: KeySource -> Annex ()
|
cleanCruft :: KeySource -> Annex ()
|
||||||
cleanCruft source = when (contentLocation source /= keyFilename source) $
|
cleanCruft source = when (contentLocation source /= keyFilename source) $
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
[[!comment format=mdwn
|
||||||
|
username="joey"
|
||||||
|
subject="""comment 28"""
|
||||||
|
date="2021-06-14T16:31:26Z"
|
||||||
|
content="""
|
||||||
|
@Ilya sure can be skipped when annex.supportunlocked=false.
|
||||||
|
I've implemented that. (And also for several other cases that have similar
|
||||||
|
behavior, like dropping a key.)
|
||||||
|
"""]]
|
|
@ -5,8 +5,8 @@ moved to AnnexRead for a performance win and also to make clean how it's
|
||||||
used. --[[Joey]]
|
used. --[[Joey]]
|
||||||
|
|
||||||
The easy things have been moved now, but some things like Annex.force and
|
The easy things have been moved now, but some things like Annex.force and
|
||||||
Annex.fast would be good to move. Moving those would involve running
|
Annex.fast and Annex.getGitConfig would be good to move. Moving those would
|
||||||
argument processing outside the Annex monad. The main reason argument
|
involve running argument processing outside the Annex monad. The main
|
||||||
processing runs in the Annex monad is to set those values, but there may be
|
reason argument processing runs in the Annex monad is to set those values,
|
||||||
other reasons too, so this will be a large set of changes that need to all
|
but there may be other reasons too, so this will be a large set of changes
|
||||||
happen together. --[[Joey]]
|
that need to all happen together. --[[Joey]]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue