From c70b78d40a1f27176cc01c8ae02355b50d5cb607 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 17 Nov 2011 18:29:28 -0400 Subject: [PATCH] migrate: Don't fall over a stale temp file. --- Command/Migrate.hs | 5 +++-- debian/changelog | 1 + doc/bugs/interrupting_migration_causes_problems.mdwn | 4 +++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Command/Migrate.hs b/Command/Migrate.hs index 860c4bd470..045b8f9b1d 100644 --- a/Command/Migrate.hs +++ b/Command/Migrate.hs @@ -48,9 +48,10 @@ perform file oldkey newbackend = do src <- fromRepo $ gitAnnexLocation oldkey tmp <- fromRepo gitAnnexTmpDir let tmpfile = tmp takeFileName file + cleantmp tmpfile liftIO $ createLink src tmpfile k <- Backend.genKey tmpfile $ Just newbackend - liftIO $ cleantmp tmpfile + cleantmp tmpfile case k of Nothing -> stop Just (newkey, _) -> do @@ -70,7 +71,7 @@ perform file oldkey newbackend = do next $ Command.Add.cleanup file newkey True else stop where - cleantmp t = whenM (doesFileExist t) $ removeFile t + cleantmp t = liftIO $ whenM (doesFileExist t) $ removeFile t link src newkey = getViaTmpUnchecked newkey $ \t -> do -- Make a hard link to the old backend's -- cached key, to avoid wasting disk space. diff --git a/debian/changelog b/debian/changelog index fd989546a3..6976fd13a8 100644 --- a/debian/changelog +++ b/debian/changelog @@ -16,6 +16,7 @@ git-annex (3.20111112) UNRELEASED; urgency=low * Fix support for insteadOf url remapping. Closes: #644278 * When not run in a git repository, git-annex can still display a usage message, and "git annex version" even works. + * migrate: Don't fall over a stale temp file. -- Joey Hess Sat, 12 Nov 2011 14:50:21 -0400 diff --git a/doc/bugs/interrupting_migration_causes_problems.mdwn b/doc/bugs/interrupting_migration_causes_problems.mdwn index 3298a1fa65..68426e54af 100644 --- a/doc/bugs/interrupting_migration_causes_problems.mdwn +++ b/doc/bugs/interrupting_migration_causes_problems.mdwn @@ -47,4 +47,6 @@ The error: failed git-annex: migrate: 1 failed - +> Fixed it to delete the stale temp file. [[done]] +> +> Thanks for making such clear test cases, Jim! --[[Joey]]