annex.thin
Decided it's too scary to make v6 unlocked files have 1 copy by default, but that should be available to those who need it. This is consistent with git-annex not dropping unused content without --force, etc. * Added annex.thin setting, which makes unlocked files in v6 repositories be hard linked to their content, instead of a copy. This saves disk space but means any modification of an unlocked file will lose the local (and possibly only) copy of the old version. * Enable annex.thin by default on upgrade from direct mode to v6, since direct mode made the same tradeoff. * fix: Adjusts unlocked files as configured by annex.thin.
This commit is contained in:
parent
bb6719678e
commit
121f5d5b0c
17 changed files with 259 additions and 146 deletions
|
@ -8,18 +8,20 @@
|
|||
module Upgrade.V5 where
|
||||
|
||||
import Common.Annex
|
||||
import qualified Annex
|
||||
import Config
|
||||
import Annex.InodeSentinal
|
||||
import Annex.Link
|
||||
import Annex.Direct
|
||||
import Annex.Content
|
||||
import Annex.WorkTree
|
||||
import Annex.CatFile
|
||||
import qualified Database.Keys
|
||||
import qualified Annex.Content.Direct as Direct
|
||||
import qualified Git
|
||||
import qualified Git.LsFiles
|
||||
import qualified Git.Branch
|
||||
import Git.FileMode
|
||||
import Git.Config
|
||||
import Utility.InodeCache
|
||||
|
||||
upgrade :: Bool -> Annex Bool
|
||||
|
@ -27,6 +29,11 @@ upgrade automatic = do
|
|||
unless automatic $
|
||||
showAction "v5 to v6"
|
||||
whenM isDirect $ do
|
||||
{- Direct mode makes the same tradeoff of using less disk
|
||||
- space, with less preservation of old versions of files
|
||||
- as does annex.thin. -}
|
||||
setConfig (annexConfig "thin") (boolConfig True)
|
||||
Annex.changeGitConfig $ \c -> c { annexThin = True }
|
||||
{- Since upgrade from direct mode changes how files
|
||||
- are represented in git, commit any changes in the
|
||||
- work tree first. -}
|
||||
|
@ -70,7 +77,9 @@ upgradeDirectWorkTree = do
|
|||
void $ liftIO clean
|
||||
where
|
||||
go (f, Just _sha, Just mode) | isSymLink mode = do
|
||||
mk <- lookupFile f
|
||||
-- Cannot use lookupFile here, as we're in between direct
|
||||
-- mode and v6.
|
||||
mk <- catKeyFile f
|
||||
case mk of
|
||||
Nothing -> noop
|
||||
Just k -> do
|
||||
|
@ -84,13 +93,13 @@ upgradeDirectWorkTree = do
|
|||
go _ = noop
|
||||
|
||||
fromdirect f k = do
|
||||
-- If linkAnnex fails for some reason, the work tree file
|
||||
-- If linkToAnnex fails for some reason, the work tree file
|
||||
-- still has the content; the annex object file is just
|
||||
-- not populated with it. Since the work tree file
|
||||
-- is recorded as an associated file, things will still
|
||||
-- work that way, it's just not ideal.
|
||||
ic <- withTSDelta (liftIO . genInodeCache f)
|
||||
void $ linkAnnex k f ic
|
||||
void $ linkToAnnex k f ic
|
||||
writepointer f k = liftIO $ do
|
||||
nukeFile f
|
||||
writeFile f (formatPointer k)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue