migrate: Detect if a file gets corrupted while it's being migrated.
This commit is contained in:
parent
b28358509f
commit
c553f56634
2 changed files with 13 additions and 7 deletions
|
@ -52,15 +52,20 @@ upgradableKey backend key = isNothing (Types.Key.keySize key) || backendupgradab
|
||||||
|
|
||||||
{- Store the old backend's key in the new backend
|
{- Store the old backend's key in the new backend
|
||||||
- The old backend's key is not dropped from it, because there may
|
- The old backend's key is not dropped from it, because there may
|
||||||
- be other files still pointing at that key. -}
|
- be other files still pointing at that key.
|
||||||
|
-
|
||||||
|
- To ensure that the data we have for the old key is valid, it's
|
||||||
|
- fscked here. First we generate the new key. This ensures that the
|
||||||
|
- data cannot get corrupted after the fsck but before the new key is
|
||||||
|
- generated.
|
||||||
|
-}
|
||||||
perform :: FilePath -> Key -> Backend -> Backend -> CommandPerform
|
perform :: FilePath -> Key -> Backend -> Backend -> CommandPerform
|
||||||
perform file oldkey oldbackend newbackend = do
|
perform file oldkey oldbackend newbackend = go =<< genkey
|
||||||
ifM (Command.Fsck.checkBackend oldbackend oldkey (Just file))
|
|
||||||
( maybe stop go =<< genkey
|
|
||||||
, stop
|
|
||||||
)
|
|
||||||
where
|
where
|
||||||
go newkey = stopUnless (Command.ReKey.linkKey oldkey newkey) $
|
go Nothing = stop
|
||||||
|
go (Just newkey) = stopUnless checkcontent $ finish newkey
|
||||||
|
checkcontent = Command.Fsck.checkBackend oldbackend oldkey $ Just file
|
||||||
|
finish newkey = stopUnless (Command.ReKey.linkKey oldkey newkey) $
|
||||||
next $ Command.ReKey.cleanup file oldkey newkey
|
next $ Command.ReKey.cleanup file oldkey newkey
|
||||||
genkey = do
|
genkey = do
|
||||||
content <- calcRepo $ gitAnnexLocation oldkey
|
content <- calcRepo $ gitAnnexLocation oldkey
|
||||||
|
|
1
debian/changelog
vendored
1
debian/changelog
vendored
|
@ -23,6 +23,7 @@ git-annex (4.20130502) UNRELEASED; urgency=low
|
||||||
* rsync special remotes: When sending from a crippled filesystem, use
|
* rsync special remotes: When sending from a crippled filesystem, use
|
||||||
the destination's default file permissions, as the local ones can
|
the destination's default file permissions, as the local ones can
|
||||||
be arbitrarily broken. (Ie, ----rwxr-x for files on Android)
|
be arbitrarily broken. (Ie, ----rwxr-x for files on Android)
|
||||||
|
* migrate: Detect if a file gets corrupted while it's being migrated.
|
||||||
|
|
||||||
-- Joey Hess <joeyh@debian.org> Thu, 02 May 2013 20:39:19 -0400
|
-- Joey Hess <joeyh@debian.org> Thu, 02 May 2013 20:39:19 -0400
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue