aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2011-03-23 17:25:28 -0400
committerGravatar Joey Hess <joey@kitenet.net>2011-03-23 17:25:28 -0400
commit8beb72e20604b0d2cc6359e75ed4eac45fcd1081 (patch)
tree8780cf25d5f304321d984bef9ea90946f3dc3576
parentaf45a62980b6b231225e4456e602eec4dfc4e04b (diff)
migrate: Bugfix for case when migrating a file results in a key that is already present in .git/annex/objects.
For example, this could happen if using SHA1 and a file with content "foo" were added to that backend. Then a file with "content" foo were migrated from the WORM backend. Assume that, if a backend assigned the same key, the already annexed content must be the same. So, the "old" content can be reused.
-rw-r--r--Command/Migrate.hs4
-rw-r--r--debian/changelog2
2 files changed, 5 insertions, 1 deletions
diff --git a/Command/Migrate.hs b/Command/Migrate.hs
index 56147113b..38dfd06b2 100644
--- a/Command/Migrate.hs
+++ b/Command/Migrate.hs
@@ -8,6 +8,7 @@
module Command.Migrate where
import Control.Monad.State (liftIO)
+import Control.Monad (unless)
import System.Posix.Files
import System.Directory
@@ -58,7 +59,8 @@ perform file oldkey newbackend = do
ok <- getViaTmpUnchecked newkey $ \t -> do
-- Make a hard link to the old backend's
-- cached key, to avoid wasting disk space.
- liftIO $ createLink src t
+ exists <- liftIO $ doesFileExist t
+ unless exists $ liftIO $ createLink src t
return True
if ok
then do
diff --git a/debian/changelog b/debian/changelog
index f124296cc..9a3ffbafa 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -13,6 +13,8 @@ git-annex (0.20110321) UNRELEASED; urgency=low
* unused: In fast mode, just show all existing temp files as unused,
and avoid expensive scan for other unused content.
* Fix space leak in fsck and drop commands.
+ * migrate: Bugfix for case when migrating a file results in a key that
+ is already present in .git/annex/objects.
-- Joey Hess <joeyh@debian.org> Tue, 22 Mar 2011 16:52:00 -0400