From 5256a6b011ba7c8ddd4e07232a5a25a5562c1b88 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 16 May 2011 12:10:08 -0400 Subject: migrate: Use current filename when generating new key, for backends where the filename affects the key name. --- Command/Migrate.hs | 12 ++++++++++-- debian/changelog | 2 ++ 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 Fri, 06 May 2011 15:20:38 -0400 -- cgit v1.2.3