found a way to make uninit always fast
To do so, I slightly changed the behavior of unannex. Now in fast mode, it only makes a hard link when the annexed file's link count is 1. This avoids unannexing 2 files with the same content in fast mode from hard linking them together. (One will end up hard linked to the annex, which the docs warn about.) With that change, uninit can simply always run unannex in fast mode. Since .git/annex/objects is being blown away anyway, there's no worry in this case about a hard link pointing into it causing an annexed object to be modified.
This commit is contained in:
parent
97210abe71
commit
03ce5cd8d2
4 changed files with 13 additions and 5 deletions
|
@ -75,7 +75,16 @@ cleanupIndirect :: FilePath -> Key -> CommandCleanup
|
|||
cleanupIndirect file key = do
|
||||
src <- calcRepo $ gitAnnexLocation key
|
||||
ifM (Annex.getState Annex.fast)
|
||||
( hardlinkfrom src
|
||||
( do
|
||||
-- Only make a hard link if the annexed file does not
|
||||
-- already have other hard links pointing at it.
|
||||
-- This avoids unannexing (and uninit) ending up
|
||||
-- hard linking files together, which would be
|
||||
-- surprising.
|
||||
s <- liftIO $ getFileStatus src
|
||||
if linkCount s > 1
|
||||
then copyfrom src
|
||||
else hardlinkfrom src
|
||||
, copyfrom src
|
||||
)
|
||||
where
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
module Command.Uninit where
|
||||
|
||||
import Common.Annex
|
||||
import qualified Annex
|
||||
import Command
|
||||
import qualified Git
|
||||
import qualified Git.Command
|
||||
|
@ -37,6 +38,7 @@ check = do
|
|||
seek :: CommandSeek
|
||||
seek ps = do
|
||||
withFilesNotInGit False (whenAnnexed startCheckIncomplete) ps
|
||||
Annex.changeState $ \s -> s { Annex.fast = True }
|
||||
withFilesInGit (whenAnnexed Command.Unannex.start) ps
|
||||
finish
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue