summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2011-05-16 12:10:08 -0400
committerGravatar Joey Hess <joey@kitenet.net>2011-05-16 12:10:08 -0400
commit5256a6b011ba7c8ddd4e07232a5a25a5562c1b88 (patch)
treec6e235cbb0f3a8fc54b141cf1f1c9e97fc4b010a
parent267eeb995b8bfb779c017086df75b4700a103485 (diff)
migrate: Use current filename when generating new key, for backends where the filename affects the key name.
-rw-r--r--Command/Migrate.hs12
-rw-r--r--debian/changelog2
2 files changed, 12 insertions, 2 deletions
diff --git a/Command/Migrate.hs b/Command/Migrate.hs
index 35855d527..790d5d365 100644
--- a/Command/Migrate.hs
+++ b/Command/Migrate.hs
@@ -8,9 +8,10 @@
module Command.Migrate where
import Control.Monad.State (liftIO)
-import Control.Monad (unless)
+import Control.Monad (unless, when)
import System.Posix.Files
import System.Directory
+import System.FilePath
import Command
import qualified Annex
@@ -52,7 +53,10 @@ perform file oldkey newbackend = do
-- The old backend's key is not dropped from it, because there may
-- be other files still pointing at that key.
let src = gitAnnexLocation g oldkey
- stored <- Backend.storeFileKey src $ Just newbackend
+ let tmpfile = gitAnnexTmpDir g </> takeFileName file
+ liftIO $ createLink src tmpfile
+ stored <- Backend.storeFileKey tmpfile $ Just newbackend
+ liftIO $ cleantmp tmpfile
case stored of
Nothing -> stop
Just (newkey, _) -> do
@@ -69,3 +73,7 @@ perform file oldkey newbackend = do
liftIO $ removeFile file
next $ Command.Add.cleanup file newkey
else stop
+ where
+ cleantmp t = do
+ exists <- doesFileExist t
+ when exists $ removeFile t
diff --git a/debian/changelog b/debian/changelog
index 666abc94e..3827a4632 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -7,6 +7,8 @@ git-annex (0.20110504) UNRELEASED; urgency=low
buckets, and allow x-archive-* headers to be specified in initremote to
set item metadata.
* Added filename extension preserving variant backends SHA1E, SHA256E, etc.
+ * migrate: Use current filename when generating new key, for backends
+ where the filename affects the key name.
-- Joey Hess <joeyh@debian.org> Fri, 06 May 2011 15:20:38 -0400