unannex: New, much slower, but more safe behavior
Copies files out of the annex. This avoids an unannex of one file breaking other files that link to the same content. Also, it means that the content remains in the annex using up space until cleaned up with "git annex unused". (The behavior of unannex --fast has not changed; it still hard links to content in the annex. --fast was not made the default because it is potentially unsafe; editing such a hard linked file can unexpectedly change content stored in the annex.)
This commit is contained in:
parent
d16d71ce86
commit
0eff0dd910
6 changed files with 41 additions and 31 deletions
|
@ -13,11 +13,11 @@ import Common.Annex
|
||||||
import Command
|
import Command
|
||||||
import Config
|
import Config
|
||||||
import qualified Annex
|
import qualified Annex
|
||||||
import Logs.Location
|
|
||||||
import Annex.Content
|
import Annex.Content
|
||||||
import Annex.Content.Direct
|
import Annex.Content.Direct
|
||||||
import qualified Git.Command
|
import qualified Git.Command
|
||||||
import qualified Git.LsFiles as LsFiles
|
import qualified Git.LsFiles as LsFiles
|
||||||
|
import Utility.CopyFile
|
||||||
|
|
||||||
def :: [Command]
|
def :: [Command]
|
||||||
def = [command "unannex" paramPaths seek SectionUtility
|
def = [command "unannex" paramPaths seek SectionUtility
|
||||||
|
@ -60,28 +60,24 @@ performIndirect file key = do
|
||||||
|
|
||||||
cleanupIndirect :: FilePath -> Key -> CommandCleanup
|
cleanupIndirect :: FilePath -> Key -> CommandCleanup
|
||||||
cleanupIndirect file key = do
|
cleanupIndirect file key = do
|
||||||
|
src <- calcRepo $ gitAnnexLocation key
|
||||||
ifM (Annex.getState Annex.fast)
|
ifM (Annex.getState Annex.fast)
|
||||||
( goFast
|
( hardlinkfrom src
|
||||||
, go
|
, copyfrom src
|
||||||
)
|
)
|
||||||
return True
|
|
||||||
where
|
where
|
||||||
#ifdef mingw32_HOST_OS
|
copyfrom src =
|
||||||
goFast = go
|
thawContent file `after` liftIO (copyFileExternal src file)
|
||||||
#else
|
hardlinkfrom src =
|
||||||
goFast = do
|
#ifndef mingw32_HOST_OS
|
||||||
-- fast mode: hard link to content in annex
|
-- creating a hard link could fall; fall back to copying
|
||||||
src <- calcRepo $ gitAnnexLocation key
|
|
||||||
-- creating a hard link could fall; fall back to non fast mode
|
|
||||||
ifM (liftIO $ catchBoolIO $ createLink src file >> return True)
|
ifM (liftIO $ catchBoolIO $ createLink src file >> return True)
|
||||||
( thawContent file
|
( return True
|
||||||
, go
|
, copyfrom src
|
||||||
)
|
)
|
||||||
|
#else
|
||||||
|
copyfrom src
|
||||||
#endif
|
#endif
|
||||||
go = do
|
|
||||||
fromAnnex key file
|
|
||||||
logStatus key InfoMissing
|
|
||||||
|
|
||||||
|
|
||||||
performDirect :: FilePath -> Key -> CommandPerform
|
performDirect :: FilePath -> Key -> CommandPerform
|
||||||
performDirect file key = do
|
performDirect file key = do
|
||||||
|
|
|
@ -38,7 +38,7 @@ check = do
|
||||||
seek :: [CommandSeek]
|
seek :: [CommandSeek]
|
||||||
seek =
|
seek =
|
||||||
[ withFilesNotInGit $ whenAnnexed startCheckIncomplete
|
[ withFilesNotInGit $ whenAnnexed startCheckIncomplete
|
||||||
, withFilesInGit $ whenAnnexed startUnannex
|
, withFilesInGit $ whenAnnexed Command.Unannex.start
|
||||||
, withNothing start
|
, withNothing start
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -51,14 +51,6 @@ startCheckIncomplete file _ = error $ unlines
|
||||||
, "Not continuing with uninit; either delete or git annex add the file and retry."
|
, "Not continuing with uninit; either delete or git annex add the file and retry."
|
||||||
]
|
]
|
||||||
|
|
||||||
startUnannex :: FilePath -> (Key, Backend) -> CommandStart
|
|
||||||
startUnannex file info = do
|
|
||||||
-- Force fast mode before running unannex. This way, if multiple
|
|
||||||
-- files link to a key, it will be left in the annex and hardlinked
|
|
||||||
-- to by each.
|
|
||||||
Annex.changeState $ \s -> s { Annex.fast = True }
|
|
||||||
Command.Unannex.start file info
|
|
||||||
|
|
||||||
start :: CommandStart
|
start :: CommandStart
|
||||||
start = next $ next $ do
|
start = next $ next $ do
|
||||||
annexdir <- fromRepo gitAnnexDir
|
annexdir <- fromRepo gitAnnexDir
|
||||||
|
|
9
debian/changelog
vendored
9
debian/changelog
vendored
|
@ -18,6 +18,15 @@ git-annex (4.20131025) UNRELEASED; urgency=low
|
||||||
(eg, on removable drives).
|
(eg, on removable drives).
|
||||||
* add: Fix reversion in 4.20130827 when adding unlocked files that have
|
* add: Fix reversion in 4.20130827 when adding unlocked files that have
|
||||||
not yet been committed.
|
not yet been committed.
|
||||||
|
* unannex: New, much slower, but more safe behavior: Copies files out of
|
||||||
|
the annex. This avoids an unannex of one file breaking other files that
|
||||||
|
link to the same content. Also, it means that the content
|
||||||
|
remains in the annex using up space until cleaned up with
|
||||||
|
"git annex unused".
|
||||||
|
(The behavior of unannex --fast has not changed; it still hard links
|
||||||
|
to content in the annex. --fast was not made the default because it is
|
||||||
|
potentially unsafe; editing such a hard linked file can unexpectedly
|
||||||
|
change content stored in the annex.)
|
||||||
|
|
||||||
-- Joey Hess <joeyh@debian.org> Sat, 26 Oct 2013 12:11:48 -0400
|
-- Joey Hess <joeyh@debian.org> Sat, 26 Oct 2013 12:11:48 -0400
|
||||||
|
|
||||||
|
|
|
@ -48,3 +48,10 @@ For this reason, it seems likely this is due to some sort of race condition.
|
||||||
This is on Ubuntu 12.04 with git-annex revision a1e2bc4.
|
This is on Ubuntu 12.04 with git-annex revision a1e2bc4.
|
||||||
|
|
||||||
|
|
||||||
|
> There was no good soluton to this, so I picked a bad one that
|
||||||
|
> will not have users complainging git-annex ate their data.
|
||||||
|
> They will complain that `git annex unannex` is slow since it now copies
|
||||||
|
> the file, and perhaps instead use --fast, and hopefully avoid destroying
|
||||||
|
> their own data by editing the resulting hard links.
|
||||||
|
>
|
||||||
|
> [[done]] --[[Joey]]
|
||||||
|
|
|
@ -50,3 +50,5 @@ Now file1.txt is a normal 6-byte file again, but 2, 3, and 4 are broken symlinks
|
||||||
git-annex 4.20130802 package
|
git-annex 4.20130802 package
|
||||||
|
|
||||||
on Debian GNU/Linux jessie/sid (testing), amd64.
|
on Debian GNU/Linux jessie/sid (testing), amd64.
|
||||||
|
|
||||||
|
> [[dup|done]] --[[Joey]]
|
||||||
|
|
|
@ -673,16 +673,20 @@ subdirectories).
|
||||||
|
|
||||||
* `unannex [path ...]`
|
* `unannex [path ...]`
|
||||||
|
|
||||||
Use this to undo an accidental `git annex add` command. You can use
|
Use this to undo an accidental `git annex add` command. It puts the
|
||||||
`git annex unannex` to move content out of the annex at any point,
|
file back how it was before the add.
|
||||||
even if you've already committed it.
|
|
||||||
|
Note that for safety, the content of the file remains in the annex (as a
|
||||||
|
hard link), until you use `git annex unused` and `git annex dropunused`.
|
||||||
|
|
||||||
This is not the command you should use if you intentionally annexed a
|
This is not the command you should use if you intentionally annexed a
|
||||||
file and don't want its contents any more. In that case you should use
|
file and don't want its contents any more. In that case you should use
|
||||||
`git annex drop` instead, and you can also `git rm` the file.
|
`git annex drop` instead, and you can also `git rm` the file.
|
||||||
|
|
||||||
In `--fast` mode, this command leaves content in the annex, simply making
|
Normally this does a slow copy of the file. In `--fast` mode, it
|
||||||
a hard link to it.
|
instead makes a hard link from the file to the content in the annex.
|
||||||
|
But use --fast mode with caution, because editing the file will
|
||||||
|
change the content in the annex.
|
||||||
|
|
||||||
* `uninit`
|
* `uninit`
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue