diff options
author | Joey Hess <joey@kitenet.net> | 2014-08-12 13:00:03 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2014-08-12 13:00:08 -0400 |
commit | 67fd45c894d48d5168faeff4c419cce8fb2fe43f (patch) | |
tree | 452ee8423f3dede5e409f950e66d68cf130ba4c7 | |
parent | da66a6384e1958994e979eeccc3f6f10a51205c6 (diff) |
direct: Fix ugly warning messages.
replaceFileOr was broken and ran the rollback action always.
Luckily, for replaceFile, the rollback action was safe to run, since it
just nuked a temp file that had already been moved into place.
However, when `git annex direct` used replaeFileOr, its rollback printed a
scary message:
/home/joey/tmp/rrrr/.git/annex/misctmp/tmp32268: rename: does not exist (No such file or directory)
There was actually no bad result though.
-rw-r--r-- | Annex/ReplaceFile.hs | 8 | ||||
-rw-r--r-- | debian/changelog | 1 |
2 files changed, 6 insertions, 3 deletions
diff --git a/Annex/ReplaceFile.hs b/Annex/ReplaceFile.hs index 8776762e9..8cb0cc6da 100644 --- a/Annex/ReplaceFile.hs +++ b/Annex/ReplaceFile.hs @@ -30,14 +30,16 @@ replaceFileOr :: FilePath -> (FilePath -> Annex ()) -> (FilePath -> Annex ()) -> replaceFileOr file action rollback = do tmpdir <- fromRepo gitAnnexTmpMiscDir void $ createAnnexDirectory tmpdir - bracket (liftIO $ setup tmpdir) rollback $ \tmpfile -> do - action tmpfile - liftIO $ catchIO (rename tmpfile file) (fallback tmpfile) + tmpfile <- liftIO $ setup tmpdir + go tmpfile `catchNonAsync` (const $ rollback tmpfile) where setup tmpdir = do (tmpfile, h) <- openTempFileWithDefaultPermissions tmpdir "tmp" hClose h return tmpfile + go tmpfile = do + action tmpfile + liftIO $ catchIO (rename tmpfile file) (fallback tmpfile) fallback tmpfile _ = do createDirectoryIfMissing True $ parentDir file moveFile tmpfile file diff --git a/debian/changelog b/debian/changelog index e83a7f518..48b6296d7 100644 --- a/debian/changelog +++ b/debian/changelog @@ -30,6 +30,7 @@ git-annex (5.20140718) UNRELEASED; urgency=medium * Windows: Now uses actual inode equivilants in new direct mode repositories, for safer detection of eg, renaming of files with the same size and mtime. + * direct: Fix ugly warning messages. -- Joey Hess <joeyh@debian.org> Mon, 21 Jul 2014 14:41:26 -0400 |