diff --git a/Database/Fsck.hs b/Database/Fsck.hs index 20b4878e39..ed00e62d80 100644 --- a/Database/Fsck.hs +++ b/Database/Fsck.hs @@ -31,6 +31,7 @@ import Types.Key import Types.UUID import Annex.Perms import Annex.LockFile +import Messages import Database.Persist.TH import Database.Esqueleto hiding (Key) @@ -77,6 +78,10 @@ openDb u = do rename tmpdbdir dbdir lockFileCached =<< fromRepo (gitAnnexFsckDbLock u) h <- liftIO $ H.openDb db "fscked" + + -- work around https://github.com/yesodweb/persistent/issues/474 + liftIO setConsoleEncoding + return $ FsckHandle h u closeDb :: FsckHandle -> Annex () diff --git a/Messages.hs b/Messages.hs index 026fca51e6..fce5c179a2 100644 --- a/Messages.hs +++ b/Messages.hs @@ -30,6 +30,7 @@ module Messages ( showHeader, showRaw, setupConsole, + setConsoleEncoding, enableDebugOutput, disableDebugOutput, debugEnabled, @@ -176,9 +177,12 @@ setupConsole = do <$> streamHandler stderr DEBUG <*> pure preciseLogFormatter updateGlobalLogger rootLoggerName (setLevel NOTICE . setHandlers [s]) - {- This avoids ghc's output layer crashing on - - invalid encoded characters in - - filenames when printing them out. -} + setConsoleEncoding + +{- This avoids ghc's output layer crashing on invalid encoded characters in + - filenames when printing them out. -} +setConsoleEncoding :: IO () +setConsoleEncoding = do fileEncoding stdout fileEncoding stderr diff --git a/debian/changelog b/debian/changelog index d0f16cf051..7a0314cc8f 100644 --- a/debian/changelog +++ b/debian/changelog @@ -7,6 +7,8 @@ git-annex (5.20150825) UNRELEASED; urgency=medium --unused-refspec option. Thanks, Øyvind A. Holm. * Make full option parsing be done when not in a git repo, so --help can be displayed for commands that require a git repo, etc. + * fsck: Work around bug in persistent that broke display of + problematically encoded filenames on stderr when using --incremental. -- Joey Hess Tue, 01 Sep 2015 14:46:18 -0700 diff --git a/doc/bugs/hPutChar_error_message_with_UTF-8_chars_above_7F_in_filenames.mdwn b/doc/bugs/hPutChar_error_message_with_UTF-8_chars_above_7F_in_filenames.mdwn index f4beac9fb7..16acb005e0 100644 --- a/doc/bugs/hPutChar_error_message_with_UTF-8_chars_above_7F_in_filenames.mdwn +++ b/doc/bugs/hPutChar_error_message_with_UTF-8_chars_above_7F_in_filenames.mdwn @@ -76,3 +76,5 @@ git-annex: fsck: 2 failed # End of transcript or log. """]] + +> [[fixed|done]] --[[Joey]] diff --git a/doc/bugs/hPutChar_error_message_with_UTF-8_chars_above_7F_in_filenames/comment_1_bb9cd3e753431b1f5dd8b94a1be4e4a3._comment b/doc/bugs/hPutChar_error_message_with_UTF-8_chars_above_7F_in_filenames/comment_1_bb9cd3e753431b1f5dd8b94a1be4e4a3._comment new file mode 100644 index 0000000000..373c1e4e7d --- /dev/null +++ b/doc/bugs/hPutChar_error_message_with_UTF-8_chars_above_7F_in_filenames/comment_1_bb9cd3e753431b1f5dd8b94a1be4e4a3._comment @@ -0,0 +1,20 @@ +[[!comment format=mdwn + username="joey" + subject="""comment 1""" + date="2015-09-09T20:14:01Z" + content=""" +It only fails with --incremental, and the only difference +is that the fsck database is opened and written that way. + +Somehow, opening the database causes the encoding of the stderr handle to get +reset from the fileEncoding git-annex normally applies at startup to +the defaut, which crashes on filenames that don't use the locale's +encoding. + +What a strange side effect especially to find in haskell code! +It's some kind of bug in persistent that this happens. +I've filed a bug: + +I put in a workaround; I have it reset the encoding of the file handles +after opening the db. +"""]]