diff options
author | Joey Hess <joey@kitenet.net> | 2011-05-16 12:10:08 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2011-05-16 12:10:08 -0400 |
commit | 5256a6b011ba7c8ddd4e07232a5a25a5562c1b88 (patch) | |
tree | c6e235cbb0f3a8fc54b141cf1f1c9e97fc4b010a /Command | |
parent | 267eeb995b8bfb779c017086df75b4700a103485 (diff) |
migrate: Use current filename when generating new key, for backends where the filename affects the key name.
Diffstat (limited to 'Command')
-rw-r--r-- | Command/Migrate.hs | 12 |
1 files changed, 10 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 |